If my procedure is following:
Result: 'Activity B' shows up (it resumes).
Result: 'Activity A' shows up (it restarts).
I want to do exactly same from the BroadcastReceiver.
My expected result: 'Activity B' shows up.
I want to do exactly same from the BroadcastReceiver.
Current result: 'Activity A' shows up.
Following code doesn't do what I expect:
public void onReceive(Context context, Intent intent) {
Intent i = new Intent(context, ActivityA.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
}
I also tried "Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY" but no luck.
My gosh, I made it working!!
Thank you for other answers you guys provided, but they weren't what I was looking for.
This will do the job:
Intent i = getPackageManager().getLaunchIntentForPackage("com.your.package.name");
i.setFlags(0);
i.setPackage(null);
startActivity(i);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With