Android APK Information Get getAppLabel(Context c, int uid)

Here you can find the source of getAppLabel(Context c, int uid)

Description

get App Label

Declaration

public static String getAppLabel(Context c, int uid) 

Method Source Code

//package com.java2s;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;

public class Main {
    public static String getAppLabel(Context c, int uid) {
        PackageManager pm = c.getPackageManager();
        String label = null;/*from w  ww .  j av a2 s . c o  m*/
        try {

            String name = pm.getPackagesForUid(uid)[0];
            label = (String) pm.getApplicationLabel(getAppInfo(c, name));
        } catch (NameNotFoundException e) {
            // 
            e.printStackTrace();
        } catch (NullPointerException e) {
            label = "unknown(uid=" + uid + ")";
        }
        return label;
    }

    private static ApplicationInfo getAppInfo(Context c, String name)
            throws NameNotFoundException {
        PackageManager pm = c.getPackageManager();
        return pm.getApplicationInfo(name,
                PackageManager.GET_UNINSTALLED_PACKAGES);
    }
}

Related

  1. getApp()
  2. getAppCacheDir(Context context)
  3. getAppContext()
  4. getAppInfo(Context c, String name)
  5. getAppInfo(Context c, String name)
  6. getAppLabel(Context c, int uid)
  7. getAppPkg(Context c, int uid)
  8. getAppPkg(Context c, int uid)
  9. getNameApkInstalledFile(String packageName, int type)