根据包名获取应用名

2017-02-10  本文已影响162人  灰灰手记
    public CharSequence getApplicationLabel(Context context, String pkgName){
        try {
            PackageManager pm = context.getPackageManager();
            ApplicationInfo appInfo = pm.getApplicationInfo(pkgName, PackageManager.GET_META_DATA);
            return pm.getApplicationLabel(appInfo);
        }
        catch (PackageManager.NameNotFoundException e) {
            e.printStackTrace();
            return null;
        }
    }
上一篇下一篇

猜你喜欢

热点阅读