本文整理汇总了Java中android.app.Activity.getBaseContext方法的典型用法代码示例。如果您正苦于以下问题:Java Activity.getBaseContext方法的具体用法?Java Activity.getBaseContext怎么用?Java Activity.getBaseContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.app.Activity
的用法示例。
在下文中一共展示了Activity.getBaseContext方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: callActivityOnCreate
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void callActivityOnCreate(Activity activity, Bundle icicle) {
final Intent intent = activity.getIntent();
if (PluginUtil.isIntentFromPlugin(intent)) {
Context base = activity.getBaseContext();
try {
LoadedPlugin plugin = this.mPluginManager.getLoadedPlugin(intent);
ReflectUtil.setField(base.getClass(), base, "mResources", plugin.getResources());
ReflectUtil.setField(ContextWrapper.class, activity, "mBase", plugin.getPluginContext());
ReflectUtil.setField(Activity.class, activity, "mApplication", plugin.getApplication());
ReflectUtil.setFieldNoException(ContextThemeWrapper.class, activity, "mBase", plugin.getPluginContext());
// set screenOrientation
ActivityInfo activityInfo = plugin.getActivityInfo(PluginUtil.getComponent(intent));
if (activityInfo.screenOrientation != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
activity.setRequestedOrientation(activityInfo.screenOrientation);
}
} catch (Exception e) {
e.printStackTrace();
}
}
mBase.callActivityOnCreate(activity, icicle);
}
示例2: callActivityOnDestroy
import android.app.Activity; //导入方法依赖的package包/类
@Override
public void callActivityOnDestroy(Activity activity) {
mBase.callActivityOnDestroy(activity);
if(activity!=null && activity.getBaseContext() instanceof ContextImplHook){
try {
Hack.HackedMethod scheduleFinalCleanup = AtlasHacks.ContextImpl.method("scheduleFinalCleanup",String.class,String.class);
if(scheduleFinalCleanup.getMethod()!=null){
scheduleFinalCleanup.invoke(((ContextImplHook)activity.getBaseContext()).getBaseContext(),
activity.getClass().getName(),"Activity");
}
} catch (Throwable e) {
e.printStackTrace();
}
}
}
示例3: hookActivityResources
import android.app.Activity; //导入方法依赖的package包/类
public static void hookActivityResources(Activity activity, String packageName) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && isVivo(activity.getResources())) {
// for 5.0+ vivo
return;
}
// designed for 5.0 - only, but some bad phones not work, eg:letv
try {
Context base = activity.getBaseContext();
final LoadedPlugin plugin = PluginManager.getInstance(activity).getLoadedPlugin(packageName);
final Resources resources = plugin.getResources();
if (resources != null) {
ReflectUtil.setField(base.getClass(), base, "mResources", resources);
// copy theme
Resources.Theme theme = resources.newTheme();
theme.setTo(activity.getTheme());
int themeResource = (int)ReflectUtil.getField(ContextThemeWrapper.class, activity, "mThemeResource");
theme.applyStyle(themeResource, true);
ReflectUtil.setField(ContextThemeWrapper.class, activity, "mTheme", theme);
ReflectUtil.setField(ContextThemeWrapper.class, activity, "mResources", resources);
}
} catch (Exception e) {
e.printStackTrace();
}
}
示例4: initActivity
import android.app.Activity; //导入方法依赖的package包/类
private void initActivity(Activity activity) {
Context appContext = activity.getBaseContext();
Money.initialize(Locale.getDefault());
ImageStore.initialize(appContext);
Configuration.initConfig(appContext);
DataProvider.getInstance().setServerCallsInstance(TestServerCalls.getInstance());
}
示例5: ErrorManager
import android.app.Activity; //导入方法依赖的package包/类
public ErrorManager(Activity activity){
this.activity = activity;
this.context = activity.getBaseContext();
mode = 1;
}