Search code examples
androidandroid-activitywindow

When Activity.attach() will be called?


When I study the Activity's create process and I found that var mWindow was initialized in Actviity'attach().like this

final void attach(Context context, ActivityThread aThread,
        Instrumentation instr, IBinder token, int ident,
        Application application, Intent intent, ActivityInfo info,
        CharSequence title, Activity parent, String id,
        NonConfigurationInstances lastNonConfigurationInstances,
        Configuration config, String referrer, IVoiceInteractor voiceInteractor) {
    attachBaseContext(context);

    mFragments.attachActivity(this, mContainer, null);

    mWindow = PolicyManager.makeNewWindow(this);
    mWindow.setCallback(this);
    mWindow.setOnWindowDismissedCallback(this);
    mWindow.getLayoutInflater().setPrivateFactory(this);
    ...
}

But I don't know when this method will be called. anyone who can answer me? thanks.


Solution

  • It's called in the function named performLaunchActivity of class ActivityThread, before onCreate.