I have an application with multiple activities. On one of them, I set up an alarm. I press the HOME button. When the alarm is triggered, a notification appears. When clicking on the notification, I start a dialogue-like Activity (@android:style/Theme.Dialog). Although I am on the desktop screen, Android opens my last activity and then shows my dialogue-like activity on top of that. I just want to show my dialogue activity wherever the user is.
Does anyone have an idea of what is wrong?
Intent notificationIntent = new Intent(this, NotificationActivity.class);
notificationIntent.putExtra(Constants.EXTRA_ALERT_MESSAGE, contentText);
PendingIntent contentIntent = PendingIntent.getActivity(this, Constants.PENDING_INTENT_REQ_DIALOG, notificationIntent, 0);
no.contentIntent = contentIntent;
You probably want to set android:taskAffinity
and android:launchMode="singleTask"
in your manifest file for your dialog activity. Setting taskAffinity
will cause that Activity
to launch in a separate task with its own stack. The singleTask
may or may not be completely appropriate for your application but you'll probably want either it or singleInstance
depending on your use case. You will need to read the documentation to determine which one will work for you.
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