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
Activity
if there is no instance and it is called. - and if any other instance of that
Activity
is 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
Activity
does 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
launchMode
tosingleTop
and this works only if theActivity
is at the top of the history stack. onNewIntent() only gets called ifActivity
is at the top of history stack. and in my case theActivity
may be at any position in stack. So this is not working.