本文整理匯總了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;
}