Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When should super.onResume() be called?

Tags:

android

When should super.onResume(); be called, on the first line of onResume() or on the last line?

protected void onResume() {     Log.i(MY_DEBUG_TAG, "On Resume");     super.onResume();     displayDashboard(); } 
like image 478
Mithun Sreedharan Avatar asked Aug 29 '11 04:08

Mithun Sreedharan


People also ask

Is onResume called after onCreate?

onResume() will never be called before onCreate() . Show activity on this post. onResume() will always be called when the activity goes into foreground, but it will never be executed before onCreate() .

Why onPause is called?

An activity can frequently transition in and out of the foreground—for example, onPause() is called when the device goes to sleep or when a dialog appears. Because this state can transition often, the code in these two methods should be fairly lightweight in order to avoid slow transitions that make the user wait.

What is onResume ()?

onResume() When the activity enters the Resumed state, it comes to the foreground, and then the system invokes the onResume() callback. This is the state in which the app interacts with the user.


1 Answers

Android’s source code can tell us everything. If you check the Activity super class you can find the following lines:

protected void onResume() {     if (DEBUG_LIFECYCLE) Slog.v(TAG, "onResume " + this);     getApplication().dispatchActivityResumed(this);     mCalled = true; } 

On this basis, no matter before or after it is called.

like image 68
Adorjan Princz Avatar answered Sep 26 '22 01:09

Adorjan Princz