Reputation: 658
I have two activites...one in A application and other in B application.
I am calling activity from A app to B app so A app activity will be in pause and throw an intent to B app activity and after B app activity, I will go back again to A app activity so A app activity should start from onrestart or onresume() as it was in onPause() but it is going to oncreate(). I am sure that the A app acitivity was not destroyed because when I hit back button it starts from resume or restart state.
Basically the two app activities runs in circular fashion like A app activity- B app Activty- A app activity - B app activity ......................... so on
One more think I see is none of them are destroyed when I hit back button then it goes to resume state so nothing is killed.
Is there any way so that my transition shld be -
A app activity - B app activity ( A pause state- B on create state) B app activity - A app activity ( B on pause state- A resume state)
Note: two activities from in diff apps
Upvotes: 0
Views: 160
Reputation: 10785
I will go back again to A app activity so A app activity should start from onrestart or onresume() as it was in onPause() but it is going to oncreate()
as @Eigor mentioned - the operating system can shout activities which stopped (not visible, and somewhere in the activity stack of the current process) in this case - Android OS will shout down the Activity without going throughonDestroy()
, but will go through the onSaveInstanceState()
callback for giving you a chance preserving any data state you'd like to restore when the activity will re-created when you'll hit the back button. the data you saved previously will be stored in the bundle param in the onCreate()
I guess because you don't knew that that's how the OS behaves it felt strange. knowing that knowledge and taking it into consideration should solve your problem
I am sure that the A app acitivity was not destroyed because when I hit back button it starts from resume or restart state.
the fact that A app activity was not destroyed in this scenario is not something you can count on, and it does not contradict what I've said before. it still in some cases be shout down by the OS without onDestroy
been call from the same reason.
about all the circulation you want to do between A and B: I think what I wrote can help you understand why it doesn't worked as you expect...
Upvotes: 0