Last active
August 29, 2015 14:02
-
-
Save jwill/6e10a96fb5cfde9dd3a3 to your computer and use it in GitHub Desktop.
t
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Shot C] The Active lifecycle is when your Activity is in the foreground and has focus. It’s actively receiving input from user events and no other Activities are obscuring it. onPause is called, and the Active lifetime ends, as soon as your Activity is partially obscured -- for example when a dialog is displayed above it for an in-app purchase, or to select another Activity to fulfill an implicit Intent. | |
To make efficient use of limited resources, you’ll want to use these signals to adjust your app’s resource burden. | |
So most updates to your UI can be paused when this lifetime ends -- announced by onPause -- but it is still visible, so you shouldn’t pause any processes that are drawing your UI. | |
The visible lifetime on the other hand, continues whenever the app is at all visible, and ends as soon as it’s completely obscured by another app, and it moves to the background. When you see onStop you know the user can’t see your app at all. | |
All of which is to say that while onCreate and onDestroy will be called at most once each time your app is run - onStart and onResume (and onPause and onStop) will likely be called many times while the app is running. | |
Now, this is where things get a little different. On almost all platforms, app lifecycles are deterministic. Generally you’ll start a program, and it’ll keep running until it either completes or the user cancels it. | |
If you look at traditional desktop development, that means your app keeps running until your user chooses “quit” or “exit” from the file menu, at which point you can save state and free resources. | |
But as we know, on Android lifecycles work a little differently. So let’s take a closer look at how. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment