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


Java PackageManager.getPackagesForUid方法代码示例

本文整理汇总了Java中android.content.pm.PackageManager.getPackagesForUid方法的典型用法代码示例。如果您正苦于以下问题:Java PackageManager.getPackagesForUid方法的具体用法?Java PackageManager.getPackagesForUid怎么用?Java PackageManager.getPackagesForUid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.content.pm.PackageManager的用法示例。


在下文中一共展示了PackageManager.getPackagesForUid方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findPackageInfo

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private static PackageInfo findPackageInfo(PackageManager pm, String pkg, int uid) {
    final String[] packages = pm.getPackagesForUid(uid);
    if (packages != null && pkg != null) {
        final int N = packages.length;
        for (int i = 0; i < N; i++) {
            final String p = packages[i];
            if (pkg.equals(p)) {
                try {
                    return pm.getPackageInfo(pkg, PackageManager.GET_SIGNATURES);
                } catch (NameNotFoundException e) {
                    Log.w(TAG, "Failed to load package " + pkg, e);
                }
            }
        }
    }
    return null;
}
 
开发者ID:ric96,项目名称:lineagex86,代码行数:18,代码来源:AppNotificationSettings.java

示例2: hasInternet

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static boolean hasInternet(int uid, Context context) {
    PackageManager pm = context.getPackageManager();
    String[] pkgs = pm.getPackagesForUid(uid);
    if (pkgs != null)
        for (String pkg : pkgs)
            if (hasInternet(pkg, context))
                return true;
    return false;
}
 
开发者ID:miankai,项目名称:MKAPP,代码行数:10,代码来源:Util.java

示例3: getApplicationNames

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static List<String> getApplicationNames(int uid, Context context) {
    List<String> listResult = new ArrayList<>();
    if (uid == 0)
        listResult.add(context.getString(R.string.title_root));
    else if (uid == 1013)
        listResult.add(context.getString(R.string.title_mediaserver));
    else if (uid == 9999)
        listResult.add(context.getString(R.string.title_nobody));
    else {
        PackageManager pm = context.getPackageManager();
        String[] pkgs = pm.getPackagesForUid(uid);
        if (pkgs == null)
            listResult.add(Integer.toString(uid));
        else
            for (String pkg : pkgs)
                try {
                    ApplicationInfo info = pm.getApplicationInfo(pkg, 0);
                    listResult.add(pm.getApplicationLabel(info).toString());
                } catch (PackageManager.NameNotFoundException ignored) {
                }
        Collections.sort(listResult);
    }
    return listResult;
}
 
开发者ID:miankai,项目名称:MKAPP,代码行数:25,代码来源:Util.java

示例4: isSystem

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public static boolean isSystem(int uid, Context context) {
    PackageManager pm = context.getPackageManager();
    String[] pkgs = pm.getPackagesForUid(uid);
    if (pkgs != null)
        for (String pkg : pkgs)
            if (isSystem(pkg, context))
                return true;
    return false;
}
 
开发者ID:miankai,项目名称:MKAPP,代码行数:10,代码来源:Util.java

示例5: isGapps

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private static boolean isGapps(PackageManager pm, int callingUid) {
    String[] packageNames = pm.getPackagesForUid(callingUid);
    if (packageNames == null) {
        return false;
    }
    for (String packageName : packageNames) {
        if (isGapps(packageName)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:brevent,项目名称:prevent,代码行数:13,代码来源:GmsUtils.java

示例6: ApplicationInfoEx

import android.content.pm.PackageManager; //导入方法依赖的package包/类
public ApplicationInfoEx(Context context, int uid) {
	mUid = uid;
	mMapAppInfo = new TreeMap<String, ApplicationInfo>();
	PackageManager pm = context.getPackageManager();
	String[] packages = pm.getPackagesForUid(uid);
	if (packages != null)
		for (String packageName : packages)
			try {
				ApplicationInfo appInfo = pm.getApplicationInfo(packageName, 0);
				mMapAppInfo.put(pm.getApplicationLabel(appInfo).toString(), appInfo);
			} catch (NameNotFoundException ignored) {
			}
}
 
开发者ID:ukanth,项目名称:XPrivacy,代码行数:14,代码来源:ApplicationInfoEx.java

示例7: getCallingPackages

import android.content.pm.PackageManager; //导入方法依赖的package包/类
/**
 * Gets the calling package names for the current transaction.
 * @param context The context to use for accessing the package manager.
 * @return The calling package names.
 */
private static String[] getCallingPackages(Context context) {
    int callingUid = Binder.getCallingUid();
    PackageManager pm = context.getApplicationContext().getPackageManager();
    return pm.getPackagesForUid(callingUid);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:11,代码来源:ExternalAuthUtils.java

示例8: getPackageName

import android.content.pm.PackageManager; //导入方法依赖的package包/类
private static String getPackageName(Context context, int uid) {
    PackageManager packageManager = context.getPackageManager();
    String[] packageList = packageManager.getPackagesForUid(uid);
    if (packageList.length != 1 || TextUtils.isEmpty(packageList[0])) return null;
    return packageList[0];
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:7,代码来源:ClientManager.java


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