上一篇(http://blog.csdn.net/niuzhucedenglu/article/details/50910369)通过覆写Activity的方法来查看Activity的生命周期,
这里对上一篇进行补充一下,看官方文档怎么说的^_^
onCreate
/**
* Called when the activity is starting. This is where most initialization
* should go: calling {@link
* activity's UI, using {@link
* with widgets in the UI, calling
* {@link
* cursors for data being displayed, etc.
*
* <p>You can call {@link
* which case onDestroy() will be immediately called without any of the rest
* of the activity lifecycle ({@link
* {@link
*
* <p><em>Derived classes must call through to the super class's
* implementation of this method. If they do not, an exception will be
* thrown.</em></p>
*
* @param savedInstanceState If the activity is being re-initialized after
* previously being shut down then this Bundle contains the data it most
* recently supplied in {@link
*
* @see
* @see
* @see
* @see
*/
onRestart
/**
* Called after {@link
* re-displayed to the user (the user has navigated back to it). It will
* be followed by {@link
*
* <p>For activities that are using raw {@link Cursor} objects (instead of
* creating them through
* {@link
* this is usually the place
* where the cursor should be requeried (because you had deactivated it in
* {@link
*
* <p><em>Derived classes must call through to the super class's
* implementation of this method. If they do not, an exception will be
* thrown.</em></p>
*
* @see
* @see
* @see
*/
onStart
/**
* Called after {@link
* the activity had been stopped, but is now again being displayed to the
* user. It will be followed by {@link
*
* <p><em>Derived classes must call through to the super class's
* implementation of this method. If they do not, an exception will be
* thrown.</em></p>
*
* @see
* @see
* @see
*/
onRestoreInstanceState
/**
* This method is called after {@link
* being re-initialized from a previously saved state, given here in
* <var>savedInstanceState</var>. Most implementations will simply use {@link
* to restore their state, but it is sometimes convenient to do it here
* after all of the initialization has been done or to allow subclasses to
* decide whether to use your default implementation. The default
* implementation of this method performs a restore of any view state that
* had previously been frozen by {@link
*
* <p>This method is called between {@link
* {@link
*
* @param savedInstanceState the data most recently supplied in {@link
*
* @see
* @see
* @see
* @see
*/
onResume
/**
* Called after {@link
* {@link
* This is a good place to begin animations, open exclusive-access devices
* (such as the camera), etc.
*
* <p>Keep in mind that onResume is not the best indicator that your activity
* is visible to the user; a system window such as the keyguard may be in
* front. Use {@link
* activity is visible to the user (for example, to resume a game).
*
* <p><em>Derived classes must call through to the super class's
* implementation of this method. If they do not, an exception will be
* thrown.</em></p>
*
* @see
* @see
* @see
* @see
*/
onPause
/**
* Called as part of the activity lifecycle when an activity is going into
* the background, but has not (yet) been killed. The counterpart to
* {@link
*
* <p>When activity B is launched in front of activity A, this callback will
* be invoked on A. B will not be created until A's {@link
* so be sure to not do anything lengthy here.
*
* <p>This callback is mostly used for saving any persistent state the
* activity is editing, to present a "edit in place" model to the user and
* making sure nothing is lost if there are not enough resources to start
* the new activity without first killing this one. This is also a good
* place to do things like stop animations and other things that consume a
* noticeable amount of CPU in order to make the switch to the next activity
* as fast as possible, or to close resources that are exclusive access
* such as the camera.
*
* <p>In situations where the system needs more memory it may kill paused
* processes to reclaim resources. Because of this, you should be sure
* that all of your state is saved by the time you return from
* this function. In general {@link
* per-instance state in the activity and this method is used to store
* global persistent data (in content providers, files, etc.)
*
* <p>After receiving this call you will usually receive a following call
* to {@link
* displayed), however in some cases there will be a direct call back to
* {@link
*
* <p><em>Derived classes must call through to the super class's
* implementation of this method. If they do not, an exception will be
* thrown.</em></p>
*
* @see
* @see
* @see
*/
onSaveInstanceState
/**
* Called to retrieve per-instance state from an activity before being killed
* so that the state can be restored in {@link
* {@link
* will be passed to both).
*
* <p>This method is called before an activity may be killed so that when it
* comes back some time in the future it can restore its state. For example,
* if activity B is launched in front of activity A, and at some point activity
* A is killed to reclaim resources, activity A will have a chance to save the
* current state of its user interface via this method so that when the user
* returns to activity A, the state of the user interface can be restored
* via {@link
*
* <p>Do not confuse this method with activity lifecycle callbacks such as
* {@link
* in the background or on its way to destruction, or {@link
* is called before destruction. One example of when {@link
* {@link
* from activity B to activity A: there is no need to call {@link
* on B because that particular instance will never be restored, so the
* system avoids calling it. An example when {@link
* not {@link
* the system may avoid calling {@link
* killed during the lifetime of B since the state of the user interface of
* A will stay intact.
*
* <p>The default implementation takes care of most of the UI per-instance
* state for you by calling {@link android.view.View
* view in the hierarchy that has an id, and by saving the id of the currently
* focused view (all of which is restored by the default implementation of
* {@link
* information not captured by each individual view, you will likely want to
* call through to the default implementation, otherwise be prepared to save
* all of the state of each view yourself.
*
* <p>If called, this method will occur before {@link
* no guarantees about whether it will occur before or after {@link
*
* @param outState Bundle in which to place your saved state.
*
* @see
* @see
* @see
*/
onStop
/**
* Called when you are no longer visible to the user. You will next
* receive either {@link
* depending on later user activity.
*
* <p>Note that this method may never be called, in low memory situations
* where the system does not have enough memory to keep your activity's
* process running after its {@link
*
* <p><em>Derived classes must call through to the super class's
* implementation of this method. If they do not, an exception will be
* thrown.</em></p>
*
* @see
* @see
* @see
* @see
*/
onDestroy
/**
* Perform any final cleanup before an activity is destroyed. This can
* happen either because the activity is finishing (someone called
* {@link
* this instance of the activity to save space. You can distinguish
* between these two scenarios with the {@link
*
* <p><em>Note: do not count on this method being called as a place for
* saving data! For example, if an activity is editing data in a content
* provider, those edits should be committed in either {@link
* {@link
* free resources like threads that are associated with an activity, so
* that a destroyed activity does not leave such things around while the
* rest of its application is still running. There are situations where
* the system will simply kill the activity's hosting process without
* calling this method (or any others) in it, so it should not be used to
* do things that are intended to remain around after the process goes
* away.
*
* <p><em>Derived classes must call through to the super class's
* implementation of this method. If they do not, an exception will be
* thrown.</em></p>
*
* @see
* @see
* @see
* @see
*/