private ActivityController<T> attach( @Nullable @WithType("android.app.Activity$NonConfigurationInstances") Object lastNonConfigurationInstances) { if (attached) { return this; } // make sure the component is enabled Context context = RuntimeEnvironment.application.getBaseContext(); context .getPackageManager() .setComponentEnabledSetting( new ComponentName(context.getPackageName(), component.getClass().getName()), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0); ShadowActivity shadowActivity = Shadow.extract(component); shadowActivity.callAttach(getIntent(), lastNonConfigurationInstances); attached = true; return this; }
public void callAttach( Intent intent, @Nullable @WithType("android.app.Activity$NonConfigurationInstances") Object lastNonConfigurationInstances) { Application application = RuntimeEnvironment.application; Context baseContext = application.getBaseContext(); ActivityInfo activityInfo; try { activityInfo = application .getPackageManager() .getActivityInfo( new ComponentName( application.getPackageName(), realActivity.getClass().getName()), PackageManager.GET_ACTIVITIES | PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { throw new RuntimeException(e); } CharSequence activityTitle = activityInfo.loadLabel(baseContext.getPackageManager()); ActivityThread activityThread = (ActivityThread) RuntimeEnvironment.getActivityThread(); Instrumentation instrumentation = activityThread.getInstrumentation(); reflector(_Activity_.class, realActivity) .callAttach( baseContext, activityThread, instrumentation,
private ActivityController<T> attach() { if (attached) { return this; } // make sure the component is enabled Context context = RuntimeEnvironment.application.getBaseContext(); context .getPackageManager() .setComponentEnabledSetting( new ComponentName(context.getPackageName(), component.getClass().getName()), PackageManager.COMPONENT_ENABLED_STATE_ENABLED, 0); ShadowActivity shadowActivity = Shadow.extract(component); shadowActivity.callAttach(getIntent()); attached = true; return this; }