Android Question Activity Cycle and Screen Going Dark

Guardian17

Active Member
Licensed User
Longtime User
If the screen timeout on my device occurs (my App is running on a Galaxy S3 phone and the screen goes dark after a period of non-use, with no orientation change and no other App being started), when I re-access the device and the screen comes back, what part(s) of the Activity Cycle will be re-run (Activity_Create; Activity_Resume; or NOTHING -- it should just re-appear as it was prior to the screen going dark without any Activity Cycles being re-run)?
 

Guardian17

Active Member
Licensed User
Longtime User
Rolf:

Thank you for replying to my post. I will look into the StateManager Tutorial shortly.

I'm curious as to why this situation is not mentioned specifically in the Activity_Pause/Resume info (since it is a fairly common occurrence).

The following quotes are from Section 9.6 of the Beginner's Guide:
Each time the activity moves from the foreground to the background Activity_Pause is called.
Activity_Pause is also called when the activity is in the foreground and a configuration change
occurs (which leads to the activity getting paused and then destroyed).
Activity_Pause is the last place to save important information.
... and slightly further in the same Section:
Activity_Resume is called right after Activity_Create finishes or after resuming a paused activity
(activity moved to the background and now it returns to the foreground).
Note that when you open a different activity (by calling StartActivity), the current activity is first
paused and then the other activity will be created if needed and (always) resumed.
As discussed above Activity_Pause is called every time the activity moves from the foreground to
the background. This can happen because:

1. A different activity was started.
2. The Home button was pressed.
3. A configuration changed event was raised (orientation changed for example).
4. The Back button was pressed.

In scenarios 1 and 2, the activity will be paused and for now kept in memory as it is expected to be
reused later.

In scenario 3 the activity will be paused, destroyed and then created (and resumed) again.

In scenario 4 the activity will be paused and destroyed. Pressing on the Back button is similar to
closing the activity. In this case you do not need to save any instance specific information (the
position of pacman in a PacMan game for example).
Does the act of the device going into its timeout condition where the screen goes dark qualify as falling under Condition (3) above? If so, what is the new configuration change condition that causes this? Or is this considered moving to the background? What other "configuration changes" qualify under Condition (3) ?
 
Last edited:
Upvote 0
Top