/** * @param newIntent * @see android.app.Activity#setIntent(android.content.Intent) */ public void setIntent(Intent newIntent) { mActivity.setIntent(newIntent); }
@Override public void setIntent(android.content.Intent intent0) { mOriginActivity.setIntent(intent0); }
public static int getId(@NonNull Activity activity) { final Intent intent = activity.getIntent(); if (intent.hasExtra(SLICK_UNIQUE_KEY)) { return intent.getIntExtra(SLICK_UNIQUE_KEY , -1); } else { int id = UUID.randomUUID().toString().hashCode(); intent.putExtra(SLICK_UNIQUE_KEY, id); activity.setIntent(intent); return id; } }
@Override public Activity newActivity(ClassLoader cl, String className, Intent intent) throws InstantiationException, IllegalAccessException, ClassNotFoundException { if (Constants.DEBUG) Log.e(TAG, "newActivity"); if (mPluginManager.hookToPluginActivity(intent)) { String targetClassName = intent.getComponent().getClassName(); PluginApp pluginApp = mPluginManager.getLoadedPluginApk(); Activity activity = mBase.newActivity(pluginApp.mClassLoader, targetClassName, intent); activity.setIntent(intent); ReflectUtil.setField(ContextThemeWrapper.class, activity, Constants.FIELD_RESOURCES, pluginApp.mResources); return activity; } if (Constants.DEBUG) Log.e(TAG, "super.newActivity(...)"); return super.newActivity(cl, className, intent); }
@Override public Activity newActivity(ClassLoader cl, String className, Intent intent) throws InstantiationException, IllegalAccessException, ClassNotFoundException { if (className.startsWith(ComponentFinder.DEFAULT_ACTIVITY_PROXY_PREFIX)) { // 插件代理Activity,替换回插件真实的Activity String[] result = IntentUtils.parsePkgAndClsFromIntent(intent); String packageName = result[0]; String targetClass = result[1]; PluginDebugLog.runtimeLog(TAG, "newActivity: " + className + ", targetClass: " + targetClass); if (!TextUtils.isEmpty(packageName)) { PluginLoadedApk loadedApk = PluginManager.getPluginLoadedApkByPkgName(packageName); if (loadedApk != null && targetClass != null) { Activity activity = mHostInstr.newActivity(loadedApk.getPluginClassLoader(), targetClass, intent); activity.setIntent(intent); if (!dispatchToBaseActivity(activity)) { // 这里需要替换Resources,是因为ContextThemeWrapper会缓存一个Resource对象,而在Activity#attach()和 // Activity#onCreate()之间,系统会调用Activity#setTheme()初始化主题,Android 4.1+ ReflectionUtils.on(activity).setNoException("mResources", loadedApk.getPluginResource()); } return activity; } else if (loadedApk == null) { // loadedApk 为空,可能是正在恢复进程,跳转到 RecoveryActivity return mHostInstr.newActivity(cl, mRecoveryHelper.selectRecoveryActivity(className), intent); } } } return mHostInstr.newActivity(cl, className, intent); }