Android: Is onResume always called after onCreate?

Android

Android Problem Overview


I need to know if there is ever an instance when onResume will be called before onCreate has been called at least once. Thanks.

Edit: Judging by the activity life cycle, it doesn't seem so. But I want to double check.

Android Solutions


Solution 1 - Android

onResume() will never be called before onCreate().

Read more about it in the Activity Lifecycle

Activity Lifecycle

Solution 2 - Android

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

Solution 3 - Android

Solution 4 - Android

I had an issue in which overridden onCreate was not getting called. I tried debugging and logging and i found oncreate not getting called.

Turns out that i override wrong onCreate

@Override
    public void onCreate(@Nullable Bundle savedInstanceState, @Nullable PersistableBundle persistentState) {
        super.onCreate(savedInstanceState, persistentState);
    }

This is the correct one.

@Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

Posting in the hope that it might help some poor soul. :)

So the correct onCreate() will always get called before onResume

Solution 5 - Android

Note: This answer only an additional one to complement the accepted answers.

As previous answers say:

onResume() will never be called before onCreate().

Read more about it in the Activity Lifecycle and Starting an Activity.

Below the complete image of Activity lifecycle including Fragment Lifecycle from android-lifecycle:

enter image description here

Solution 6 - Android

the activity has its own lifecycle . just read and look at the nice graph here:

http://developer.android.com/reference/android/app/Activity.html

onResume doesn't suppose to run before onCreate , so you assume correctly .

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestioncapcomView Question on Stackoverflow
Solution 1 - AndroidSamView Answer on Stackoverflow
Solution 2 - AndroidWroclaiView Answer on Stackoverflow
Solution 3 - AndroidKarthik RkView Answer on Stackoverflow
Solution 4 - Androidhushed_voiceView Answer on Stackoverflow
Solution 5 - Androidישו אוהב אותךView Answer on Stackoverflow
Solution 6 - Androidandroid developerView Answer on Stackoverflow