您的位置:首页 > Web前端

Understand the Lifecycle Callbacks

2013-07-29 00:00 190 查看


Implementing your activity lifecycle methods properly ensures your app behaves well in several ways, including that it:

Does not crash if the user receives a phone call or switches to another app while using your app.

Does not consume valuable system resources when the user is not actively using it.

Does not lose the user's progress if they leave your app and return to it at a later time.

Does not crash or lose the user's progress when the screen rotates between landscape and portrait orientation.

the activity can exist in one of only three states for an extended period of time:

Resumed
In this state, the activity is in the foreground and the user can interact with it. (Also sometimes referred to as the "running" state.)

Paused
In this state, the activity is partially obscured by another activity—the other activity that's in the foreground is semi-transparent or doesn't cover the entire screen. The paused activity does not receive user input and cannot execute any code.

Stopped
In this state, the activity is completely hidden and not visible to the user; it is considered to be in the background. While stopped, the activity instance and all its state information such as member variables is retained, but it cannot execute any code.

The other states (Created and Started) are transient and the system quickly moves from them to the next state by calling the next lifecycle callback method
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  官网学android