How to start activity from broadcast receiver
It’s simple - just create Intent and invoke startActivity, but you may get strange runtime error. To prevent it, make sure you set intent flag:
public void onReceive(Context context, Intent intent) {
Intent launchIntent = new Intent(context, MyActivity.class);
launchIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK );
context.startActivity(launchIntent);
}
BTW, if you combine it with Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS your activity will not be shown in “recent apps” list (you see it when press and hold Home button).
