Here is what i am having an issue with:
i am starting an activity by pressing the notification bar which contains an extra to mark that the activity is started from notifications. i use this flag in the oncreate method of my activity (Which is the main screen of my app) to launch a new screen on top of that one if the extra from notifications is set.
so that part works great. now what happens is when i click the notifications and i exit the app by pressing the back key, if i afterwards restart it from the recent’s by pressing the home button it seems to redeliver that last intent that came from the notifications so it starts my screen again. i have tried a bunch of flags in the manifest and i haven’t been successful so far.
here are the flags i am using for the activity.
android:clearTaskOnLaunch="true"
android:alwaysRetainTaskState="false"
any ideas here?
thank you.
OK so it turns out that if your activity is declared singleTop then the last intent is getting redelivered every time you start the activity by pressing the home button.
as a workaround i tried using the onConfiguration changed to save a flag when the intent was used but it didn’t work because the activity was actually destroyed and it wasn’t just changing orientation. finally what i did was save that flag in shared preferences and set it to false every time i send a new intent towards the singleTop activity and setting it to true every time the intent extras are consumed.
so problem dirty fixed, but i am curious of how behavior like this is normal :(.