I have a scenario like:- There are three Ativities A, B, C.
1. A's launch mode is 'singleTask' and C's launchmode is 'singleTop' in manifest. A calls B and then B calls C.
2. Now C is the top most activity of the application stack.
3. Now Activity C is put to background by presseing device home key.
4. I have a service running which Sends broadcast for every say 15 mins.
5. In broadcast receiver i have an intent which is like this
Intent i = new Intent(context, A.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
context.startActivity(i);
Now Activity 'A' comes in foreground and in its onResume() i call Activity 'C' as ACTIVITY_RESET_TASK_IF_NEEDED (have some flag that tells me that Activity 'C' was invoked alreday, so lets bring it in foreground. If that flag is set to false then it would never invoke Activity 'C' directly rather Activity 'B' will get called and then 'B' will call Activity 'C').
What i trying to achieve here is the user perspection that when Activity 'C' was running then that Activity 'C' should come in foreground.
Here is the Problem now:- I never get the same Actvity 'C' instance due to FLAG_ACTIVITY_NEW_TASK and thus my app goes in wierd state. But when my app is put to background using device back key and i exceute all those steps it works i.e i get the same instance of Activity 'C' (Don't know how android is handling it internally this, but in both the flows home and back key there is not consistency).
So how do i achieve or maintain my app state in case for home key being pressed..?
Help Appreciated.