Android onRestart调用时机

2017-10-23  本文已影响318人  smileshane

onRestart调用时机

官方阐述:

onRestart

void onRestart ()

Called after onStop() when the current activity is being re-displayed to the user (the user has navigated back to it). It will be followed by onStart() and then onResume().
For activities that are using raw Cursor objects (instead of creating them through managedQuery(android.net.Uri, String[], String, String[], String), this is usually the place where the cursor should be requeried (because you had deactivated it in onStop().
Derived classes must call through to the super class's implementation of this method. If they do not, an exception will be thrown.
If you override this method you must call through to the superclass implementation.

个人解读

官方解释强调再次显示activiy时,onRestart会被调用。再次显示有2种情况:

@Override
protected void onRestart() {
    // If you override this method you must call through to the superclass implementation
    super.onRestart();
}
上一篇 下一篇

猜你喜欢

热点阅读