I want to keep a single instance of every Activity I start in my application. The launchMode singleTask was an option but it is working for only one Activity.
I want
- to start an
Activityif there is no instance and it is called. - and if any other instance of that
Activityis present already then that instance will brought to front without creating a new instance of thatActivity. - This property will be applied to more than one
Activity. - No
Activitydoes guarantee that it will be always on the top of the history stack.
My work until now:
I got many suggestions which are not valid for my case, so I want to point these out so that no other person would give the same suggestion.
- I have set the
launchModetosingleTopand this works only if theActivityis at the top of the history stack. onNewIntent() only gets called ifActivityis at the top of history stack. and in my case theActivitymay be at any position in stack. So this is not working.