当前位置: 首页>>代码示例>>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;未经允许,请勿转载。