Jim
Jim

Reputation: 55

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.

Upvotes: 5

Views: 2649

Answers (1)

neuo
neuo

Reputation: 733

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

Upvotes: 4

Related Questions