So I'm trying to start a new activity from my onReceive
function in a `BroadcastReceiver, yet I seem to be crashing. Without further adieu here is the code:
public void onReceive(Context context, Intent intent) {
//... other stuff th开发者_Go百科at's not relevant
Intent j = new Intent(context, myClass.class);
context.startActivity(j);
//If I comment the above two lines out and replace with a Toast, the toast shows up
}
Thoughts?
Edit - did some more testing, and I can start this activity from other places using the same kind of intent. I just can't do it from the BroadcastReceiver
...
Thanks.
Try this:
Intent j = new Intent(context, myClass.class);
j.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(j);
精彩评论