Android examples for App:APK Information
get App Label
//package com.java2s; import android.content.Context; import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; import android.content.pm.PackageManager.NameNotFoundException; public class Main { public static String getAppLabel(Context context, String packageName) { PackageManager pkgManager = context.getPackageManager(); if (pkgManager == null) return null; PackageInfo pkgInfo;/*from w ww .j av a 2 s . com*/ try { pkgInfo = pkgManager.getPackageInfo(packageName, 0); if (pkgInfo == null) return null; } catch (NameNotFoundException e) { e.printStackTrace(); return null; } ApplicationInfo appInfo = pkgInfo.applicationInfo; if (appInfo == null) return null; CharSequence cs = appInfo.loadLabel(pkgManager); if (cs == null) return null; return cs.toString(); } public static PackageInfo getPackageInfo(Context context, String packageName, int flag) { PackageManager manager = context.getPackageManager(); if (manager == null) return null; try { return manager.getPackageInfo(packageName, flag); } catch (NameNotFoundException e) { e.printStackTrace(); return null; } } }