当前位置: 首页>>代码示例>>Java>>正文


Java Activity.getBaseContext方法代码示例

本文整理汇总了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);
}
 
开发者ID:didi,项目名称:VirtualAPK,代码行数:26,代码来源:VAInstrumentation.java

示例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();
	}
}
  }
 
开发者ID:alibaba,项目名称:atlas,代码行数:16,代码来源:InstrumentationHook.java

示例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();
    }
}
 
开发者ID:didi,项目名称:VirtualAPK,代码行数:28,代码来源:PluginUtil.java

示例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());
}
 
开发者ID:WGPlaner,项目名称:wg_planer,代码行数:8,代码来源:RegistrationActivitySteps.java

示例5: ErrorManager

import android.app.Activity; //导入方法依赖的package包/类
public ErrorManager(Activity activity){
    this.activity = activity;
    this.context = activity.getBaseContext();
    mode = 1;
}
 
开发者ID:Onelio,项目名称:ConnectU,代码行数:6,代码来源:ErrorManager.java


注:本文中的android.app.Activity.getBaseContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。