List of usage examples for android.content.pm PackageManager getApplicationInfo
public abstract ApplicationInfo getApplicationInfo(String packageName, @ApplicationInfoFlags int flags) throws NameNotFoundException;
From source file:Main.java
public static String getAppName(Context context, String packageName) { try {//from w w w .java 2 s .c o m PackageManager pm = context.getPackageManager(); ApplicationInfo info = pm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); return pm.getApplicationLabel(info).toString(); } catch (Exception e) { return ""; } }
From source file:Main.java
public static boolean isApkDebuggable(Application application) { PackageManager pm = application.getPackageManager(); try {//from w ww .ja v a 2s . co m return ((pm.getApplicationInfo(application.getPackageName(), 0).flags & ApplicationInfo.FLAG_DEBUGGABLE) > 0); } catch (NameNotFoundException e) { return false; } }
From source file:Main.java
public static boolean checkIsInstallHuaweiAccount(Context context) { PackageManager packMgr = context.getPackageManager(); try {//from www . ja v a 2s . c o m return (null != packMgr.getApplicationInfo("com.huawei.hwid", PackageManager.GET_META_DATA)); } catch (NameNotFoundException e) { return false; } }
From source file:Main.java
public static boolean isDebuggable(Context context) { PackageManager pm = context.getPackageManager(); try {/*from ww w. jav a 2 s. c o m*/ ApplicationInfo info = pm.getApplicationInfo(context.getPackageName(), 0); return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; } catch (PackageManager.NameNotFoundException e) { } return true; }
From source file:Main.java
public static Drawable appIconLookup(Context context, String packageName) { try {/*from w w w .j a v a 2 s.c om*/ PackageManager pm = context.getPackageManager(); ApplicationInfo ai = pm.getApplicationInfo(packageName, 0); return pm.getApplicationIcon(ai); } catch (final PackageManager.NameNotFoundException e) { e.printStackTrace(); Log.e("AppsHelper", "Could not find icon for " + packageName); return null; } }
From source file:Main.java
public static String getAppName(Context context) { try {//from ww w.j a va2 s . c o m PackageManager packageManager = context.getPackageManager(); ApplicationInfo appInfo = packageManager.getApplicationInfo(context.getPackageName(), 0); return (String) packageManager.getApplicationLabel(appInfo); } catch (Exception e) { e.printStackTrace(); } return ""; }
From source file:Main.java
public static String appNameLookup(Context context, String packageName) { try {/*from w w w. j a v a2 s .c o m*/ PackageManager pm = context.getPackageManager(); ApplicationInfo ai = pm.getApplicationInfo(packageName, 0); return pm.getApplicationLabel(ai).toString(); } catch (final PackageManager.NameNotFoundException e) { e.printStackTrace(); Log.e("AppsHelper", "Could not resolve name " + packageName); return null; } }
From source file:Main.java
/** * Get app name/*from www. j a v a 2 s . c o m*/ * * @param context * @param packageName * @return */ public static String getAppName(Context context, String packageName) { try { PackageManager pm = context.getPackageManager(); ApplicationInfo info = pm.getApplicationInfo(packageName, 0); return info.loadLabel(pm).toString(); } catch (NameNotFoundException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static String getAppMetadata(Context context, String key) { String strValue = ""; try {//from w w w.ja v a2s. c om PackageManager mgr = context.getPackageManager(); Bundle bundle = mgr.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA).metaData; //Bundle bundle = context.getApplicationInfo().metaData; if (bundle != null && bundle.containsKey(key)) { strValue = bundle.getString(key); } } catch (Exception e) { Log.w(LOG_TAG, e); } return strValue; }
From source file:Main.java
/** * Get app icon/*from w w w. j a va 2 s.c o m*/ * * @param context * @param packageName * @return */ public static Drawable getAppIcon(Context context, String packageName) { try { PackageManager pm = context.getPackageManager(); ApplicationInfo info = pm.getApplicationInfo(packageName, 0); return info.loadIcon(pm); } catch (NameNotFoundException e) { e.printStackTrace(); } return null; }