PackageManager getPackagesForUid - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for PackageManager getPackagesForUid method.

This code example shows how to use the following methods:checkSignatures, getPackagesForUid
		final String pname = getPackageNameByUid(uid);
		return checkSignature(pname);
	} 
 
	public boolean checkSignature(final String pname) {
		return mPackageManager.checkSignatures(pname, mContext.getPackageName()) == PackageManager.SIGNATURE_MATCH;
	} 
 
	public boolean deny(final String package_name) {
		if (package_name == null) return false;
		final SharedPreferences.Editor editor = mPreferences.edit();
		editor.putInt(package_name, PERMISSION_DENIED);
		return editor.commit();
 
	} 
 
	public int getPermissions(final int uid) {
		return getPermissions(getPackageNameByUid(uid));
	} 
 

6
CodeRank
This code example shows how to use the following methods:getApplicationIcon, getApplicationInfo, getPackagesForUid
 
    public static Drawable getAppIcon(Context c, int uid) {
        PackageManager pm = c.getPackageManager();
        Drawable appIcon = c.getResources().getDrawable(
                android.R.drawable.sym_def_app_icon);
        String[] packages = pm.getPackagesForUid(uid);
 
        if (packages != null) {
            if (packages.length == 1) {
                try { 
                    ApplicationInfo appInfo = pm.getApplicationInfo(
                            packages[0], 0);
                    appIcon = pm.getApplicationIcon(appInfo);
                } catch (NameNotFoundException e) {
                    Log.e(c.getPackageName(),
                            "No package found matching with the uid " + uid);
                } 
            } 
        } else { 
            Log.e(c.getPackageName(), "Package not found for uid " + uid);
6
CodeRank
This code example shows how to use the following methods:getPackagesForUid
        return appName;
    } 
 
    public static String getAppPackage(Context c, int uid) {
        PackageManager pm = c.getPackageManager();
        String[] packages = pm.getPackagesForUid(uid);
        String appPackage = "unknown";
 
        if (packages != null) {
            if (packages.length == 1) {
                appPackage = packages[0];
            } else if (packages.length > 1) {
                appPackage = "Multiple packages";
            } 
        } else { 
            Log.e(TAG, "Package not found");
        } 
 
        return appPackage;
    } 
5
CodeRank
This code example shows how to use the following methods:getPackagesForUid
        return wrapped.checkSignatures(uid1, uid2);
    } 
 
    @Override 
    public String[] getPackagesForUid(int uid) {
        return wrapped.getPackagesForUid(uid);
    } 
 
    @Override 
    public String getNameForUid(int uid) {
        return wrapped.getNameForUid(uid);
    } 
 
    @Override 
    public List<ApplicationInfo> getInstalledApplications(int flags) {
        return wrapped.getInstalledApplications(flags);
    } 
 
    @Override 
    public ResolveInfo resolveActivity(Intent intent, int flags) {
4
CodeRank

Related PackageManager getPackagesForUid Questions & Answers:

getPackagesForUid Method Overview
Retrieve the names of all packages that are associated with a particular user id.
See Code Examples for other Android PackageManager Methods: