question

fu-gamazing avatar image
fu-gamazing asked

Weird activity life cycle.

Hi, I encountered an weird activity life cycle on Kindle Fire HD 7'' (2nd Gen). How to reproduce. 1) install an app 2) switch off the screen 3) look at logs the log. 08-19 16:14:51.252: WARN/ActivityManager(201): Force removing ActivityRecord{41bee100 com.example.thefirstandroidapp/.MyActivity15}: app died, no saved state 08-19 16:14:53.861: INFO/ActivityStack(201): START {flg=0x10000000 cmp=com.example.thefirstandroidapp/.MyActivity15} from pid 29614 08-19 16:14:53.861: VERBOSE/ActivityStack(201): Prepare open transition: starting ActivityRecord{415d8100 com.example.thefirstandroidapp/.MyActivity15} 08-19 16:14:53.963: INFO/ActivityManager(201): Start proc com.example.thefirstandroidapp for activity com.example.thefirstandroidapp/.MyActivity15: pid=29641 uid=10059 gids={3003, 1015} 08-19 16:14:54.150: DEBUG/MyActivity15(29641): onCreate 08-19 16:14:54.150: DEBUG/MyActivity15(29641): onStart 08-19 16:14:54.150: DEBUG/MyActivity15(29641): onResume 08-19 16:14:54.314: DEBUG/MyActivity15(29641): onPause 08-19 16:14:54.330: VERBOSE/ActivityStack(201): Prepare open transition: prev=ActivityRecord{415d8100 com.example.thefirstandroidapp/.MyActivity15} 08-19 16:14:54.705: DEBUG/MyActivity15(29641): onResume 08-19 16:14:54.830: INFO/ActivityManager(201): Displayed com.example.thefirstandroidapp/.MyActivity15: +890ms (total +23s331ms) // The screen is off 08-19 16:15:13.564: DEBUG/MyActivity15(29641): onPause 08-19 16:15:13.572: DEBUG/MyActivity15(29641): onStop 08-19 16:16:30.275: DEBUG/MyActivity15(29641): onRestart 08-19 16:16:30.275: DEBUG/MyActivity15(29641): onStart 08-19 16:16:30.275: DEBUG/MyActivity15(29641): onResume 08-19 16:16:30.291: DEBUG/MyActivity15(29641): onPause 08-19 16:16:30.299: DEBUG/MyActivity15(29641): onStop 08-19 16:18:59.252: DEBUG/MyActivity15(29641): onRestart 08-19 16:18:59.252: DEBUG/MyActivity15(29641): onStart 08-19 16:18:59.252: DEBUG/MyActivity15(29641): onResume 08-19 16:18:59.252: DEBUG/MyActivity15(29641): onPause 08-19 16:18:59.252: DEBUG/MyActivity15(29641): onStop 08-19 16:30:04.744: DEBUG/MyActivity15(29641): onRestart 08-19 16:30:04.744: DEBUG/MyActivity15(29641): onStart 08-19 16:30:04.744: DEBUG/MyActivity15(29641): onResume 08-19 16:30:04.744: DEBUG/MyActivity15(29641): onPause 08-19 16:30:04.752: DEBUG/MyActivity15(29641): onStop What is wrong: the activity restarts after stopping while the screen is switched off Can you suggest how to understand that the activity is becoming visible to the user? code: public class MyActivity15 extends Activity { public static String TAG = "MyActivity15"; @Override protected void onCreate(Bundle bundle) { super.onCreate(bundle); Log.d(TAG, "onCreate"); } @Override protected void onStart() { super.onStart(); Log.d(TAG, "onStart"); } @Override protected void onRestart() { super.onRestart(); Log.d(TAG, "onRestart"); } @Override protected void onResume() { super.onResume(); Log.d(TAG, "onResume"); } @Override protected void onPause() { Log.d(TAG, "onPause"); super.onPause(); } @Override protected void onStop() { Log.d(TAG, "onStop"); super.onStop(); } @Override protected void onDestroy() { Log.d(TAG, "onDestroy"); super.onDestroy(); } }
fire tablet
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

Sujoy@Amazon avatar image
Sujoy@Amazon answered
We observe this issue only on 2nd Gen Fire Tablets. 3rd and 4th Gen devices do not have this issue. A solution was provided by a third party developer here : https://forums.developer.amazon.com/forums/thread.jspa?messageID=7026
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.