android - Problems understanding the life cycle when screen goes off and on -


Info: My device is a Nexus One with 2.2 and I have tested two projects, one on 1.5 and one on 2.1. <<

Problem: I have trouble understanding the screen and the life cycle of my application.

Here is my output

  / / activity starts 08-04 17: 24: 17.643: error / play activity (6215): executed on ... 08 -04 17: 24: 17.643: Error / Play Activity (6215): On Resume Performed ... // Screen Shuts Off 08-04 17: 24: 28.943: Error / Play Activity (6215): On Pauses Implemented. .. 08-04 17: 24: 32.113: Error / Play activity (6215): Onest option ... 08-04 17: 24: 32.113: Error / Play activity (6215): execution of On Destory ... 08- 04 17: 24: 32.983: Error / Play Act Viti (6215): Performed on the ... 08-04 17:24 24: 32.983: Error / Play Activity (6215): OnResume executed ... 08-04 17:24 24: 32.983: Error / Play Activity (6215): onPause Execute ... // goes to screen 08-04 17: 24: 47.683: Error / Play Activity (6215): Performed on Honor. .. // locked 0 8-04 17: 24: 56.943: Error / Play activity (6215): On Pauses implemented ... 08-04 17: 24: 59.663: Error / Play activity (6215): Onest option. .. 08-04 17: 24: 59.663: Error / Play Activity (6215): Execution of On Destory ... 08-04 17: 25: 00.943: Error / Play Activity (6215): Performed OnStart ... 08- 04 17: 25: 00.943: Error / Play activity (6215): Execute executed ...  

I am completely confused why is the activity restarted when the screen is off? And why stop it and start over again when the screen was already running and only the lock was removed?

To ensure that I have not done anything wrong, I have just created a new project with this activity. Output is equally ...

  public class extension of LifeCycleTest activity (personal last fixed string DEBUG_TAG = "FirstLifeLog"; Crate on Public Zero (Bundled Saved Instance) {Super. Saved InstantState); log.E (DEBUG_TAG, "Executed on ..."); setContentView (R.layout.main);} Reserved Secure Zero () {Super Log A.A. (DEBUG_TAG, "Perform Onr ... . ");} Start at the protected void {super.start (); log (a.debug tag," ons Performed the program ...);} Secure zero at the reserve () {super.onResume (); log.a (DEBUG_TAG, "Honorsum executed ...");} protected at zero (reason) {super.onPause () ; Log.a (DEBUG_TAG, "On-Paused Implementation ...");} Safe void onStop () {super.onStop (); Log A (DEBUG_TAG, "Onstop execution ...");} Safe void onDestroy ) {Super.onDestroy (); Log A. (DEBUG_TAG, "OndaStra implemented ...");  

Do anyone have an idea?

Today Update from (do not understand why it is not the last time, why not If there are more free resources?)

  // Activity starts 08-09 12: 14: 03.122: Error / First Life Log (15406): On Creation Execute ... 08-09 12: 14: 03.132: Error / First Life Log (15406): Performs Onstart. .. 08-09 12: 14: 03.132: Error / First Life Log (15406): On Resume Performed ... // Screen Shutdown 08-09 12: 14: 07.412: Error / First Life Log (15406): On Pause Executes ... // On screen 08-09 12: 14: 11.722: Error / First Life Log (15406): Performs On Resume ... // No Log for Deleted Screen Lock  

See the documentation for a good description of the lifecycle, with diagrams.

With the screen your activity may die, it stops to save resources (battery power). According to the documentation, you can basically kill anytime that Android wants to free resources. Therefore, you should always design your activities so that any time off and restart.


Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -