Differences between OnStart () and Onresume () in the Android Activity lifecycle

Source: Internet
Author: User

First, learn about the four states of activity

Running state: After a new activity has been launched into the stack, it is at the top of the screen at the topmost point of the stack, where it is visible and can interact with the user in the active state.
Paused state: State when activity is overwritten by another transparent or dialog-style activity . At this point it remains connected to the window manager, the system continues to maintain its internal state, it is still visible, but it has lost focus and therefore cannot interact with the user.
Stopped state: Activity is in stopped state when activity is not visible. When activity is in this state, be sure to save the current data and the current UI state, otherwise the current data and UI state will be lost once the activity exits or shuts down.
Killed status: The activity was killed or was started before it was in killed state. This is the activity that has been removed from the activity stack and needs to be restarted before it can be displayed and used.

In 4 states, the running state and the paused state are visible, stopped state and killed state are not visible.

The difference between OnStart () and Onresume ()

OnStart () is performed when the activity interface is displayed, and the user is visible, including an activity on top of him, but not completely covered, and the user can see part of the activity but cannot interact with it
Onresume () is executed when the activity interacts with the user, and the user can gain focus on the activity and be able to interact with the user.


OnStart () is usually onstop () (that is, the user presses the home key, the activity becomes the background), and then the user switches back to the activity to call Onrestart () and then OnStart ()
Onresume () is onpause (usually the current acitivty is paused, such as being overwritten by another transparent or dialog-style activity ), then dialog is canceled and the activity returns to the interactive state, Call Onresume ().

Extension: After testing, the OnPause () method will not be called when the dialog is ejected, but will be called when overridden by another transparent or dialog-style activity.

Reference: Pause (pause) and resume (re-return) of activity's life cycle

Activity life cycle

Differences between OnStart () and Onresume () in the Android Activity lifecycle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.