I'm setting an activity, Receiver, as the content intent for a notification.
Intent clickIntent = new Intent(context, Receiver.class);
mBuilder.setContentIntent(PendingIntent.getActivity(context, 0, clickIntent, PendingIntent.FLAG_UPDATE_CURRENT));
Inside Receiver Activity, I'm starting activities which are intended to be opened using TaskStackBuilder in the following way.
Intent intent = new Intent(this, Class.forName(className));
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
TaskStackBuilder.create(this).addParentStack(Class.forName(className)).addNextIntent(intent).startActivities();
When the app is in the background and a notification click happens, it resumes the ParentActivity. Especially when device goes to idle and comes back. Any help? I'm cracking my head on this.
For an Android app, you should also declare
android:launchModein your androidManifest.xml file.As discussed in the Android documentation:
Solution given in this SO post - resuming an activity from a notification might also help.