tags:

views:

24

answers:

1

Suppose my application P started Activity A, and A started Activity B, then the activity stack contained A and B, with B at the top.

After that, I opened other apps by pressing Home button. Suppose after a while, the process of application P is killed by the OS. Then, I press Home button to select application P. At this time, which activity will be brought to the front, Activity A or Activity B?

Thanks.

A: 

If the application was killed, then Activity A would be started and brought to the front on application restart. This happens because your manifest specifies that Activity A is launched when the app icon is clicked.

(Of course, if your application wasn't killed, then your original activity stack would reappear - B at the top with A underneath)

Andy Zhang
I am still confused.The situation is that, manifest specifies that Activity E is lauched when app icon is clicked.When app P is lunched, the app starts E, then E starts A and finished itself. Then, A starts B. Now the stack contains A and B with B on the top.After a while process is killed, and then I select app P by long-pressing Home. At this time, which activity should be brought to front, E, A or B? Thanks.
E would be brought to front. This is because once the process is killed, your original stack (A and B with B on the top) no longer exists, and thus the application must start from E again.
Andy Zhang
It is weird. I checked the log, and find A got started while E didn't.
The issue is that. I didn't launch app P from Home screen the second time. I just selected app P after app history by long-pressing the Home button.
Hmm that is very strange. I experimented a little on my Nexus One. I launched my application from the home screen, which opened Activity A. A then started B and finished. I pressed home and went to Manage Applications and force stopped my application. Then I launched the application again by long-pressing the Home button. This launched Activity A again, instead of B.
Andy Zhang
I didn't the same experiment on my Nexus One too. If force stopped App E, and relaunching it from long-pressing Home button, activity E started. It worked as you expected. But it may be different, if I leave the app E for at long time (e.g. over a night), then re-select it again.