开发者

Is it possible to add a Context to an Intent to use with SendBroadcast?

开发者 https://www.devze.com 2023-03-19 06:41 出处:网络
I need to send a context as part of a SendBroadcast() call. Is this Possible? I have searched but cannot seem to find a solution.

I need to send a context as part of a SendBroadcast() call. Is this Possible? I have searched but cannot seem to find a solution.

I need to broadcast to a service running under system server to display an alert dialog. when I use the context from system server I get the following exception:

E/AndroidRuntime( 2049): Caused by: android.view.WindowManager$BadTokenExceptio开发者_如何学Cn: Unable to add window -- token null is not for an application


No this is not possible. But the receiver of the broadcast should have its own context that you can use.

Why do you want to send a Context?

EDIT A service cannot display a Dialog. A Service can post i.e. a notification to the status bar or you can start one of your activities.

0

精彩评论

暂无评论...
验证码 换一张
取 消