android.app.Instrumentation.newActivity()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(272)

本文整理了Java中android.app.Instrumentation.newActivity()方法的一些代码示例,展示了Instrumentation.newActivity()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Instrumentation.newActivity()方法的具体详情如下:
包路径:android.app.Instrumentation
类名称:Instrumentation
方法名:newActivity

Instrumentation.newActivity介绍

暂无

代码示例

代码示例来源:origin: android-hacker/VirtualXposed

@Override
public Activity newActivity(ClassLoader cl, String className, Intent intent)
    throws InstantiationException, IllegalAccessException, ClassNotFoundException {
  return base.newActivity(cl, className, intent);
}

代码示例来源:origin: android-hacker/VirtualXposed

@Override
public Activity newActivity(Class<?> clazz, Context context, IBinder token, Application application, Intent intent,
    ActivityInfo info, CharSequence title, Activity parent, String id, Object lastNonConfigurationInstance)
    throws InstantiationException, IllegalAccessException {
  return base.newActivity(clazz, context, token, application, intent, info, title, parent, id,
      lastNonConfigurationInstance);
}

代码示例来源:origin: Tencent/tinker

@Override
public Activity newActivity(ClassLoader cl, String className, Intent intent) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
  if (processIntent(cl, intent)) {
    return super.newActivity(cl, intent.getComponent().getClassName(), intent);
  } else {
    return super.newActivity(cl, className, intent);
  }
}

代码示例来源:origin: Tencent/tinker

@Override
public Activity newActivity(Class<?> clazz, Context context, IBinder token, Application application, Intent intent, ActivityInfo info, CharSequence title, Activity parent, String id, Object lastNonConfigurationInstance) throws InstantiationException, IllegalAccessException {
  processIntent(context.getClassLoader(), intent);
  return super.newActivity(clazz, context, token, application, intent, info, title, parent, id, lastNonConfigurationInstance);
}

代码示例来源:origin: bzsome/VirtualApp-x326

@Override
public Activity newActivity(ClassLoader cl, String className, Intent intent)
    throws InstantiationException, IllegalAccessException, ClassNotFoundException {
  return base.newActivity(cl, className, intent);
}

代码示例来源:origin: darkskygit/VirtualApp

@Override
public Activity newActivity(ClassLoader cl, String className, Intent intent)
    throws InstantiationException, IllegalAccessException, ClassNotFoundException {
  return base.newActivity(cl, className, intent);
}

代码示例来源:origin: limpoxe/Android-Plugin-Framework

return real.newActivity(cl, className, intent);
} catch (ClassNotFoundException e) {

代码示例来源:origin: darkskygit/VirtualApp

@Override
public Activity newActivity(Class<?> clazz, Context context, IBinder token, Application application, Intent intent,
    ActivityInfo info, CharSequence title, Activity parent, String id, Object lastNonConfigurationInstance)
    throws InstantiationException, IllegalAccessException {
  return base.newActivity(clazz, context, token, application, intent, info, title, parent, id,
      lastNonConfigurationInstance);
}

代码示例来源:origin: bzsome/VirtualApp-x326

@Override
public Activity newActivity(Class<?> clazz, Context context, IBinder token, Application application, Intent intent,
    ActivityInfo info, CharSequence title, Activity parent, String id, Object lastNonConfigurationInstance)
    throws InstantiationException, IllegalAccessException {
  return base.newActivity(clazz, context, token, application, intent, info, title, parent, id,
      lastNonConfigurationInstance);
}

代码示例来源:origin: henrymorgen/android-advanced-decode

public Activity newActivity(ClassLoader cl, String className, Intent intent) throws InstantiationException,
    IllegalAccessException, ClassNotFoundException {
  String intentName = intent.getStringExtra(HookHelper.TARGET_INTENT_NAME);
  if (!TextUtils.isEmpty(intentName)) {
    return super.newActivity(cl, intentName, intent);
  }
  return super.newActivity(cl, className, intent);
}

代码示例来源:origin: ximsfei/Android-plugin-support

@Override
public Activity newActivity(ClassLoader cl, String className, Intent intent)
    throws InstantiationException, IllegalAccessException, ClassNotFoundException {
  String clsName = intent.getStringExtra(DynamicConstants.DYNAMIC_ACTIVITY_FLAG);
  if (clsName != null) className = clsName;
  return super.newActivity(cl, className, intent);
}

代码示例来源:origin: iReaderAndroid/ZeusPlugin

@Override
  public Activity newActivity(ClassLoader cl, String className, Intent intent) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    if(intent != null){
      Bundle bundle = intent.getExtras();
      if(bundle != null){
        //给Bundle设置classLoader以使Bundle中序列化对象可以直接转化为插件中的对象
        //类似于在宿主中这么使用:TestInPlugin testInPlugin = (TestInPlugin)bundle.get("TestInPlugin");
        //TestInPlugin是在插件中定义的,如果不这么设置则会找不到TestInPlugin类
        bundle.setClassLoader(PluginManager.mNowClassLoader);
        if(className.equals("com.zeus.ZeusActivityForStandard")) {
          String realActivity = bundle.getString(PluginConstant.PLUGIN_REAL_ACTIVITY);
          if (!TextUtils.isEmpty(realActivity)) {
            return super.newActivity(cl, realActivity, intent);
          }
        }
      }
    }
    return super.newActivity(cl, className, intent);
  }
}

代码示例来源:origin: luili16/UIMocker

@Override
@CallSuper
public Activity newActivity(ClassLoader cl, String className,
              Intent intent)
    throws InstantiationException, IllegalAccessException,
    ClassNotFoundException {
  if (DEBUG) {
    Logger.d(TAG,"newActivity(ClassLoader cl, String className,Intent intent)");
  }
  return mInstrumentation.newActivity(cl, className, intent);
}

代码示例来源:origin: luili16/UIMocker

"Object lastNonConfigurationInstance)");
return mInstrumentation.newActivity(clazz, context, token, application, intent, info,
    title, parent, id, lastNonConfigurationInstance);

代码示例来源:origin: RealMoMo/Study_Android_Demo

@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);
}

代码示例来源:origin: iqiyi/Neptune

@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);
}

代码示例来源:origin: com.uphyca/android-junit4-robolectric

String id = null;
  newActivity = (T) getInstrumentation().newActivity(mActivityClass, mActivityContext, token, mApplication, intent, info, title, mMockParent, id, lastNonConfigurationInstance);
} catch (Exception e) {
  assertNotNull(newActivity);

相关文章

Instrumentation类方法