Search in sources :

Example 56 with PackageManager

use of android.content.pm.PackageManager in project weiciyuan by qii.

the class CrashManagerConstants method loadFromContext.

public static void loadFromContext(Context context) {
    CrashManagerConstants.ANDROID_VERSION = android.os.Build.VERSION.RELEASE;
    CrashManagerConstants.PHONE_MODEL = android.os.Build.MODEL;
    CrashManagerConstants.PHONE_MANUFACTURER = android.os.Build.MANUFACTURER;
    PackageManager packageManager = context.getPackageManager();
    try {
        PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0);
        CrashManagerConstants.APP_VERSION = "" + packageInfo.versionCode;
        CrashManagerConstants.APP_PACKAGE = packageInfo.packageName;
    } catch (PackageManager.NameNotFoundException e) {
        e.printStackTrace();
    }
}
Also used : PackageManager(android.content.pm.PackageManager) PackageInfo(android.content.pm.PackageInfo)

Example 57 with PackageManager

use of android.content.pm.PackageManager in project platform_frameworks_base by android.

the class OpenExternalDirectoryActivity method getAppLabel.

private static String getAppLabel(Activity activity) {
    final String packageName = activity.getCallingPackage();
    final PackageManager pm = activity.getPackageManager();
    try {
        return pm.getApplicationLabel(pm.getApplicationInfo(packageName, 0)).toString();
    } catch (NameNotFoundException e) {
        logInvalidScopedAccessRequest(activity, SCOPED_DIRECTORY_ACCESS_ERROR);
        Log.w(TAG, "Could not get label for package " + packageName);
        return null;
    }
}
Also used : PackageManager(android.content.pm.PackageManager) NameNotFoundException(android.content.pm.PackageManager.NameNotFoundException)

Example 58 with PackageManager

use of android.content.pm.PackageManager in project platform_frameworks_base by android.

the class FilesAppPerfTest method killProviders.

private void killProviders() throws Exception {
    final Context context = getInstrumentation().getContext();
    final PackageManager pm = context.getPackageManager();
    final ActivityManager am = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    final Intent intent = new Intent(DocumentsContract.PROVIDER_INTERFACE);
    final List<ResolveInfo> providers = pm.queryIntentContentProviders(intent, 0);
    for (ResolveInfo info : providers) {
        final String packageName = info.providerInfo.packageName;
        am.killBackgroundProcesses(packageName);
    }
}
Also used : Context(android.content.Context) ResolveInfo(android.content.pm.ResolveInfo) PackageManager(android.content.pm.PackageManager) Intent(android.content.Intent) ActivityManager(android.app.ActivityManager)

Example 59 with PackageManager

use of android.content.pm.PackageManager in project platform_frameworks_base by android.

the class IconUtils method loadPackageIcon.

public static Drawable loadPackageIcon(Context context, String authority, int icon) {
    if (icon != 0) {
        if (authority != null) {
            final PackageManager pm = context.getPackageManager();
            final ProviderInfo info = pm.resolveContentProvider(authority, 0);
            if (info != null) {
                return pm.getDrawable(info.packageName, icon, info.applicationInfo);
            }
        } else {
            return context.getDrawable(icon);
        }
    }
    return null;
}
Also used : PackageManager(android.content.pm.PackageManager) ProviderInfo(android.content.pm.ProviderInfo)

Example 60 with PackageManager

use of android.content.pm.PackageManager in project platform_frameworks_base by android.

the class AccessPoint method getSavedNetworkSummary.

public String getSavedNetworkSummary() {
    WifiConfiguration config = mConfig;
    if (config != null) {
        PackageManager pm = mContext.getPackageManager();
        String systemName = pm.getNameForUid(android.os.Process.SYSTEM_UID);
        int userId = UserHandle.getUserId(config.creatorUid);
        ApplicationInfo appInfo = null;
        if (config.creatorName != null && config.creatorName.equals(systemName)) {
            appInfo = mContext.getApplicationInfo();
        } else {
            try {
                IPackageManager ipm = AppGlobals.getPackageManager();
                appInfo = ipm.getApplicationInfo(config.creatorName, 0, /* flags */
                userId);
            } catch (RemoteException rex) {
            }
        }
        if (appInfo != null && !appInfo.packageName.equals(mContext.getString(R.string.settings_package)) && !appInfo.packageName.equals(mContext.getString(R.string.certinstaller_package))) {
            return mContext.getString(R.string.saved_network, appInfo.loadLabel(pm));
        }
    }
    return "";
}
Also used : WifiConfiguration(android.net.wifi.WifiConfiguration) PackageManager(android.content.pm.PackageManager) IPackageManager(android.content.pm.IPackageManager) IPackageManager(android.content.pm.IPackageManager) ApplicationInfo(android.content.pm.ApplicationInfo) SpannableString(android.text.SpannableString) RemoteException(android.os.RemoteException)

Aggregations

PackageManager (android.content.pm.PackageManager)1482 Intent (android.content.Intent)505 ResolveInfo (android.content.pm.ResolveInfo)460 NameNotFoundException (android.content.pm.PackageManager.NameNotFoundException)353 PackageInfo (android.content.pm.PackageInfo)270 ApplicationInfo (android.content.pm.ApplicationInfo)253 ComponentName (android.content.ComponentName)241 ArrayList (java.util.ArrayList)158 ActivityInfo (android.content.pm.ActivityInfo)140 IOException (java.io.IOException)127 RemoteException (android.os.RemoteException)105 Drawable (android.graphics.drawable.Drawable)94 IPackageManager (android.content.pm.IPackageManager)93 Resources (android.content.res.Resources)91 PendingIntent (android.app.PendingIntent)75 XmlPullParserException (org.xmlpull.v1.XmlPullParserException)69 Context (android.content.Context)68 Bundle (android.os.Bundle)60 HashMap (java.util.HashMap)55 ServiceInfo (android.content.pm.ServiceInfo)48