本文整理汇总了Java中android.app.Instrumentation.newApplication方法的典型用法代码示例。如果您正苦于以下问题:Java Instrumentation.newApplication方法的具体用法?Java Instrumentation.newApplication怎么用?Java Instrumentation.newApplication使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Instrumentation
的用法示例。
在下文中一共展示了Instrumentation.newApplication方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: makeApplication
import android.app.Instrumentation; //导入方法依赖的package包/类
private Application makeApplication(boolean forceDefaultAppClass, Instrumentation instrumentation) {
if (null != this.mApplication) {
return this.mApplication;
}
String appClass = this.mPackage.applicationInfo.className;
if (forceDefaultAppClass || null == appClass) {
appClass = "android.app.Application";
}
try {
this.mApplication = instrumentation.newApplication(this.mClassLoader, appClass, this.getPluginContext());
instrumentation.callApplicationOnCreate(this.mApplication);
return this.mApplication;
} catch (Exception e) {
e.printStackTrace();
return null;
}
}
示例2: createApplication
import android.app.Instrumentation; //导入方法依赖的package包/类
/** Returns a prepared application with the onCreate method already called. */
public <T extends Application> T createApplication(Class<T> appClass) {
assertNull("Application already created", application);
T app;
try {
app = (T) Instrumentation.newApplication(appClass, getContext());
} catch (Exception e) {
throw new RuntimeException("Could not create application " + appClass, e);
}
app.onCreate();
application = app;
return app;
}
示例3: newApplication
import android.app.Instrumentation; //导入方法依赖的package包/类
public static Application newApplication(Class<?> clazz, Context context)
throws InstantiationException, IllegalAccessException, ClassNotFoundException {
return Instrumentation.newApplication(clazz, context);
}