I’m not sure if this question has been asked before, but I can’t seem to find any references to it. I hope I can get some help here.
Currently I have an application with two activities, Activity Main and Activity Dialog.
Activity Main is my MAIN activity that starts when the app is launched from the home screen.
Activity Dialog has <activity style="@android:style/Theme.Dialog"> declared in the manifest so that it looks like a dialog.
And then I create a notification as such (not full code):
Intent notificationIntent = new Intent(ActivityMain.this, ActivityDialog.class);
PendingIntent contentIntent = PendingIntent.getActivity(ActivityMain.this, 0, notificationIntent, 0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
mNotificationManager.notify(ID, notification);
What I am trying to achieve is to show the user Activity Dialog as a dialog (containing some relevant information) when the user selects the notification. The user can then dismiss the dialog and continue whatever they were doing.
Unfortunately, this way does not seem to work as clicking on the notification will result in Activity Main launching first, filling up the screen, and then Activity Dialog displaying the information as a dialog.
Is there any way I can create a notification which will launch Activity Dialog on its own? Even though Activity Dialog is not the MAIN activity?
Try adding
FLAG_ACTIVITY_NEW_TASKas a flag on yourIntentand see if that helps. I suspect what you’re seeing is Android launchingActivityDialoginto an existing task that is runningActivityMain.