Java Code Examples for android.app.Instrumentation#newApplication()

The following examples show how to use android.app.Instrumentation#newApplication() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LoadedPlugin.java    From VirtualAPK with Apache License 2.0 6 votes vote down vote up
protected Application makeApplication(boolean forceDefaultAppClass, Instrumentation instrumentation) throws Exception {
    if (null != this.mApplication) {
        return this.mApplication;
    }

    String appClass = this.mPackage.applicationInfo.className;
    if (forceDefaultAppClass || null == appClass) {
        appClass = "android.app.Application";
    }

    this.mApplication = instrumentation.newApplication(this.mClassLoader, appClass, this.getPluginContext());
    // inject activityLifecycleCallbacks of the host application
    mApplication.registerActivityLifecycleCallbacks(new ActivityLifecycleCallbacksProxy());
    instrumentation.callApplicationOnCreate(this.mApplication);
    return this.mApplication;
}
 
Example 2
Source File: DbTest.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
public Application createApplication(Class class1)
{
    assertNull("Application already created", application);
    Application application1;
    try
    {
        application1 = Instrumentation.newApplication(class1, getContext());
    }
    catch (Exception exception)
    {
        throw new RuntimeException((new StringBuilder()).append("Could not create application ").append(class1).toString(), exception);
    }
    application1.onCreate();
    application = application1;
    return application1;
}
 
Example 3
Source File: InstrumentationDelegate.java    From container with GNU General Public License v3.0 4 votes vote down vote up
public static Application newApplication(Class<?> clazz, Context context)
		throws InstantiationException, IllegalAccessException, ClassNotFoundException {
	return Instrumentation.newApplication(clazz, context);
}
 
Example 4
Source File: ForageFunctionalTestRunner.java    From Forage with Mozilla Public License 2.0 4 votes vote down vote up
@Override
@NonNull
public Application newApplication(@NonNull ClassLoader cl, @NonNull String className, @NonNull Context context)
        throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    return Instrumentation.newApplication(ForageFunctionalTestApplication.class, context);
}
 
Example 5
Source File: UseApplicationInterceptor.java    From android-spock with Apache License 2.0 4 votes vote down vote up
@Override public void interceptSetupMethod(IMethodInvocation invocation) throws Throwable {
  final Application application =
      Instrumentation.newApplication(applicationClass, instrumentation.getTargetContext());
  fieldInfo.writeValue(invocation.getInstance(), application);
  invocation.proceed();
}
 
Example 6
Source File: MyInstrumentationTestRunner.java    From JayPS-AndroidApp with MIT License 4 votes vote down vote up
@Override
public Application newApplication(ClassLoader cl, String className, Context context) throws InstantiationException, IllegalAccessException, ClassNotFoundException {
    return Instrumentation.newApplication(TestApplication.class, context);
}