當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。