Issue
Today I was trying to simulate low memory condition for an Android application in eclipse. But I have found a strange behavior. Let me describe the scenario.
Start an activity and call another activity by pressing a button from first activity. Now from Eclipse->DDMS->Devices click on "Stop process".
What I've seen that none of the callback called from second activity, and the process died immediately. And after that ActivityManager has started a new process and first activity got created.
Note : First activity = MainActivity.java and second one is AnotherActivity.java
02-24 09:01:04.740: I/ActivityManager(286): Process com.algopundit.lifecycle (pid 1378) has died.
02-24 09:01:04.740: W/ActivityManager(286): Force removing ActivityRecord{419fd8e8 u0 com.algopundit.lifecycle/.AnotherActivity}: app died, no saved state
02-24 09:01:04.752: I/WindowState(286): WIN DEATH: Window{41a418f0 u0 com.algopundit.lifecycle/com.algopundit.lifecycle.MainActivity}
02-24 09:01:05.090: I/ActivityManager(286): Start proc com.algopundit.lifecycle for activity com.algopundit.lifecycle/.MainActivity: pid=1412 uid=10053 gids={50053, 1028}
02-24 09:01:06.730: V/MainActivity(1412): onCreate
02-24 09:01:07.632: V/MainActivity(1412): onStart
02-24 09:01:07.632: V/MainActivity(1412): onRestoreInstanceState
02-24 09:01:07.660: V/MainActivity(1412): onResume
02-24 09:01:08.260: V/MainActivity(1412): onAttachedToWindow
My doubt is why even onPause of AnotherActivity was not called and when process recreated by ActivityManager why AnotherActivity was not recreated?
Solution
OK People, I got the answer. In case of low memory condition as logs says system killed the process and when the new process starts it tries to find an activity with action as main and category as launcher. that's why MainActivity recreated.
Answered By - AlgoPundit
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.