I'm having problem with managing activities in history stack.
Background:
I've two Activities: Main and Preference.
I've Broadcast receiver that starts a notification at boot. The notification starts Main activity. The flags are: Intent.FLAG_ACTIVITY_CLEAR_TOP|Intent.FLAG_ACTIVITY_SINGLE_TOP for the intent and for notification Notification.FLAG_AUTO_CANCEL. (In most tutorial, broadcast receiver started a service which started notification. But I'm starting notification directly on broadcastreceiver. It's working fine for me but just a heads up.)
The intent for starting preference activity has no flags set.
Problem
- Start Main activity from Launcher and open Preference activity.
- While in Preference activity click notification which launches Main activity again. Open preference activity again.
- Press Home and launch the application which opens Main activity.
- Now if I click back instead of exiting the app I get to Preference activity(the one opened earlier) and another back moves me to Main activity(the one opened earlier).
In my last app I had used activityMode="singleInstance" to get rid of new instance of activities getting created from notification. But I want to fix this one with better way, i.e. using correct Flags.