Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 645
Jim Avatar asked Sep 27 '22 01:09

Jim


1 Answers

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

like image 187
neuo Avatar answered Oct 05 '22 23:10

neuo