I wrote an app, that brings up a notification every certain time via an alarmIntent. The user clicks on the notification and gets into an activity. After doing something in this activity he should press a button to return to the original app he was in (like a browser, or the homescreen, etc.), before clicking on the notification. My problem is, that the user always returns to the main activity of my application. How can I change that?
Thank you!
try adding this lines in your Activity
There are two types of Activity started by Notification : regular & special. Regular Activity always return to Launcher or your previous activity. Special Activity will return to your Application.
As your description, you should use Regular Activity and get PendingIntent by TaskStackBuilder, it will create an artificial back stack for notification activity.
for example :
And this is the document, you can find detail here. http://developer.android.com/guide/topics/ui/notifiers/notifications.html
Try
Activity.finish()
inside the button click listener function. This is similar to pressing the back button.So I found the solution finaly: you need to add the Intent.FLAG_ACTIVITY_MULTIPLE_TASKS flag to the intent as explained in that question: Go back to previous screen on backbutton pressed after responding to notification