當前位置: 首頁>>代碼示例>>Java>>正文


Java Context.createPackageContext方法代碼示例

本文整理匯總了Java中android.content.Context.createPackageContext方法的典型用法代碼示例。如果您正苦於以下問題:Java Context.createPackageContext方法的具體用法?Java Context.createPackageContext怎麽用?Java Context.createPackageContext使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.content.Context的用法示例。


在下文中一共展示了Context.createPackageContext方法的14個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getPackageContext

import android.content.Context; //導入方法依賴的package包/類
public static Context getPackageContext(Context context, String packageName) {
    Context pkgContext = null;
    if (context.getPackageName().equals(packageName)) {
        pkgContext = context;
    } else {
        // 創建第三方應用的上下文環境
        try {
            pkgContext = context.createPackageContext(packageName,
                    Context.CONTEXT_IGNORE_SECURITY
                            | Context.CONTEXT_INCLUDE_CODE);
        } catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
        }
    }
    return pkgContext;
}
 
開發者ID:junchenChow,項目名稱:exciting-app,代碼行數:17,代碼來源:CommonUtil.java

示例2: getThemeColor

import android.content.Context; //導入方法依賴的package包/類
/** [這個好像好用些] */
public static int getThemeColor(Context context, int themeRes, int attribute, int defaultColor) {
    int themeColor = 0;
    String packageName = context.getPackageName();
    try {
        Context packageContext = context.createPackageContext(packageName, 0);
        packageContext.setTheme(themeRes);
        Resources.Theme theme = packageContext.getTheme();
        TypedArray ta = theme.obtainStyledAttributes(new int[] {attribute});
        themeColor = ta.getColor(0, defaultColor);
        ta.recycle();
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
    return themeColor;
}
 
開發者ID:A-Miracle,項目名稱:QiangHongBao,代碼行數:17,代碼來源:ResourcesUtils.java

示例3: getString

import android.content.Context; //導入方法依賴的package包/類
private static String getString(int resId, Context context) throws PackageManager.NameNotFoundException {
    try {
        Context appContext = context.createPackageContext("ml.qingsu.fuckview", Context.CONTEXT_IGNORE_SECURITY);
        return appContext.getResources().getString(resId);
    } catch (NullPointerException e) {
        return null;
    }
}
 
開發者ID:w568w,項目名稱:fuckView,代碼行數:9,代碼來源:Hook.java

示例4: createPackageContext

import android.content.Context; //導入方法依賴的package包/類
private Context createPackageContext(String packageName) {
    try {
        Context hostContext = VirtualCore.get().getContext();
        return hostContext.createPackageContext(packageName, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
    } catch (PackageManager.NameNotFoundException e) {
        VirtualRuntime.crash(new RemoteException());
    }
    throw new RuntimeException();
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:10,代碼來源:VClientImpl.java

示例5: init

import android.content.Context; //導入方法依賴的package包/類
private void init(Context context) {
    if (init) return;
    init = true;
    if (notification_panel_width == 0) {
        Context systemUi = null;
        try {
            systemUi = context.createPackageContext(NotificationCompat.SYSTEM_UI_PKG, Context.CONTEXT_IGNORE_SECURITY);
        } catch (PackageManager.NameNotFoundException e) {
        }
        if (Build.VERSION.SDK_INT <= 19) {
            notification_side_padding = 0;
        } else {
            notification_side_padding = getDimem(context, systemUi, "notification_side_padding",
                    R.dimen.notification_side_padding);
        }
        notification_panel_width = getDimem(context, systemUi, "notification_panel_width",
                R.dimen.notification_panel_width);
        if (notification_panel_width <= 0) {
            notification_panel_width = context.getResources().getDisplayMetrics().widthPixels;
        }
        notification_min_height = getDimem(context, systemUi, "notification_min_height",
                R.dimen.notification_min_height);
        // getDimem(context, systemUi, "notification_row_min_height", 0);
        // if (notification_min_height == 0) {
        // notification_min_height =
        // }
        notification_max_height = getDimem(context, systemUi, "notification_max_height",
                R.dimen.notification_max_height);
        notification_mid_height = getDimem(context, systemUi, "notification_mid_height",
                R.dimen.notification_mid_height);
        notification_padding = getDimem(context, systemUi, "notification_padding", R.dimen.notification_padding);
        // notification_collapse_second_card_padding
    }
}
 
開發者ID:7763sea,項目名稱:VirtualHook,代碼行數:35,代碼來源:RemoteViewsFixer.java

示例6: createPackageContext

import android.content.Context; //導入方法依賴的package包/類
private Context createPackageContext(String packageName) {
    try {
        Context hostContext = VirtualCore.get().getContext();
        return hostContext.createPackageContext(packageName, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
        VirtualRuntime.crash(new RemoteException());
    }
    throw new RuntimeException();
}
 
開發者ID:coding-dream,項目名稱:TPlayer,代碼行數:11,代碼來源:VClientImpl.java

示例7: getGbContext

import android.content.Context; //導入方法依賴的package包/類
public static synchronized Context getGbContext(Context context) throws Throwable {
    if (mGbContext == null) {
        mGbContext = context.createPackageContext(GravityBox.PACKAGE_NAME,
                Context.CONTEXT_IGNORE_SECURITY);
    }
    return mGbContext;
}
 
開發者ID:WrBug,項目名稱:GravityBox,代碼行數:8,代碼來源:Utils.java

示例8: getPluginDefaultSharedPreferences

import android.content.Context; //導入方法依賴的package包/類
/**
 * Get plugin default shared preferences
 *
 * @param context current locatorContext
 * @param pkg     package name
 * @return default shared preferences
 */
static SharedPreferences getPluginDefaultSharedPreferences(@NonNull final Context context, final String pkg)
{
	try
	{
		final Context pluginContext = context.createPackageContext(pkg, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
		return PreferenceManager.getDefaultSharedPreferences(pluginContext);
	}
	catch (@NonNull final NameNotFoundException ignored)
	{
		//
	}
	return null;
}
 
開發者ID:1313ou,項目名稱:Treebolic,代碼行數:21,代碼來源:Utils.java

示例9: createPackageContext

import android.content.Context; //導入方法依賴的package包/類
private Context createPackageContext(String packageName) {
    try {
        Context hostContext = VirtualCore.get().getContext();
        return hostContext.createPackageContext(packageName, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException(e);
    }
}
 
開發者ID:codehz,項目名稱:container,代碼行數:9,代碼來源:VClientImpl.java

示例10: getAppContext

import android.content.Context; //導入方法依賴的package包/類
private Context getAppContext(Context base, String packageName) {
	try {
		return base.createPackageContext(packageName,
				Context.CONTEXT_IGNORE_SECURITY | Context.CONTEXT_INCLUDE_CODE);
	} catch (PackageManager.NameNotFoundException e) {
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:codehz,項目名稱:container,代碼行數:10,代碼來源:NotificationHandler.java

示例11: init

import android.content.Context; //導入方法依賴的package包/類
private void init(Context context) {
	if (notification_panel_width == 0) {
		Context systemUi = null;
		try {
			systemUi = context.createPackageContext("com.android.systemui", Context.CONTEXT_IGNORE_SECURITY);
		} catch (PackageManager.NameNotFoundException e) {
		}
		if (Build.VERSION.SDK_INT <= 19) {
			notification_side_padding = 0;
		} else {
			notification_side_padding = getDimem(context, systemUi, "notification_side_padding",
					R.dimen.notification_side_padding);
		}
		notification_panel_width = getDimem(context, systemUi, "notification_panel_width",
				R.dimen.notification_panel_width);
		if (notification_panel_width <= 0) {
			notification_panel_width = context.getResources().getDisplayMetrics().widthPixels;
		}
		notification_min_height = getDimem(context, systemUi, "notification_min_height",
				R.dimen.notification_min_height);
		// getDimem(context, systemUi, "notification_row_min_height", 0);
		// if (notification_min_height == 0) {
		// notification_min_height =
		// }
		notification_max_height = getDimem(context, systemUi, "notification_max_height",
				R.dimen.notification_max_height);
		notification_mid_height = getDimem(context, systemUi, "notification_mid_height",
				R.dimen.notification_mid_height);
		notification_padding = getDimem(context, systemUi, "notification_padding", R.dimen.notification_padding);
		// notification_collapse_second_card_padding
	}
}
 
開發者ID:codehz,項目名稱:container,代碼行數:33,代碼來源:RemoteViewsUtils.java

示例12: init

import android.content.Context; //導入方法依賴的package包/類
private void init(Context context) {
	if (init) return;
	init = true;
	if (notification_panel_width == 0) {
		Context systemUi = null;
		try {
			systemUi = context.createPackageContext(NotificationCompat.SYSTEM_UI_PKG, Context.CONTEXT_IGNORE_SECURITY);
		} catch (PackageManager.NameNotFoundException e) {
		}
		if (Build.VERSION.SDK_INT <= 19) {
			notification_side_padding = 0;
		} else {
			notification_side_padding = getDimem(context, systemUi, "notification_side_padding",
					R.dimen.notification_side_padding);
		}
		notification_panel_width = getDimem(context, systemUi, "notification_panel_width",
				R.dimen.notification_panel_width);
		if (notification_panel_width <= 0) {
			notification_panel_width = context.getResources().getDisplayMetrics().widthPixels;
		}
		notification_min_height = getDimem(context, systemUi, "notification_min_height",
				R.dimen.notification_min_height);
		// getDimem(context, systemUi, "notification_row_min_height", 0);
		// if (notification_min_height == 0) {
		// notification_min_height =
		// }
		notification_max_height = getDimem(context, systemUi, "notification_max_height",
				R.dimen.notification_max_height);
		notification_mid_height = getDimem(context, systemUi, "notification_mid_height",
				R.dimen.notification_mid_height);
		notification_padding = getDimem(context, systemUi, "notification_padding", R.dimen.notification_padding);
		// notification_collapse_second_card_padding
	}
}
 
開發者ID:codehz,項目名稱:container,代碼行數:35,代碼來源:RemoteViewsFixer.java

示例13: getClassLoader

import android.content.Context; //導入方法依賴的package包/類
/**
 * Get package class loader
 *
 * @param context current locatorContext
 * @param pkgName package name
 * @return package class loader
 * @throws NameNotFoundException name not found exception
 */
static ClassLoader getClassLoader(@NonNull final Context context, final String pkgName) throws NameNotFoundException
{
	final Context providerContext = context.createPackageContext(pkgName, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
	return providerContext.getClassLoader();
}
 
開發者ID:1313ou,項目名稱:Treebolic,代碼行數:14,代碼來源:Utils.java

示例14: getResources

import android.content.Context; //導入方法依賴的package包/類
/**
 * Get package resources
 *
 * @param context current locatorContext
 * @param pkgName package name
 * @return package resources
 * @throws NameNotFoundException name not found exception
 */
static Resources getResources(@NonNull final Context context, final String pkgName) throws NameNotFoundException
{
	final Context providerContext = context.createPackageContext(pkgName, Context.CONTEXT_INCLUDE_CODE | Context.CONTEXT_IGNORE_SECURITY);
	return providerContext.getResources();
}
 
開發者ID:1313ou,項目名稱:Treebolic,代碼行數:14,代碼來源:Utils.java


注:本文中的android.content.Context.createPackageContext方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。