开发者

I want to call the start Activity in BroadcastReceiver in android

I want to call the start Activ开发者_JS百科ity in BroadcastReceiver in android. I know it is a service and we cant call an activity from a service.


I want to call the start Activity in BroadcastReceiver in android.

Call startActivity() on the Context passed in as a parameter.

I know it is a service

A BroadcastReceiver is not a Service.

and we cant call an activity from a service.

Yes, you can call startActivity() in a Service.

However, calling startActivity() from either a BroadcastReceiver or a Service may not be what the user wants. You have no idea what the user is doing, and you might be taking over the foreground in the middle of something else. Please only use this in places where the user will value the interruption, or offer alternatives (e.g., a SharedPreference to indicate that you should use a Notification instead of starting an activity).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜