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
private static ApplicationInfo getAppInfoByMETA(Context context) throws PackageManager.NameNotFoundException { PackageManager pm = context.getPackageManager(); return pm.getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); }
From source file:Main.java
public static ApplicationInfo loadApplicationInfo(PackageManager mPm, String packageName) { try {//from w ww . j ava 2s . c o m return mPm.getApplicationInfo(packageName, PackageManager.GET_META_DATA); } catch (NameNotFoundException e) { return null; } }
From source file:Main.java
public static boolean packageInstalled(Context context, String packageName) { boolean ret = false; PackageManager pm = context.getPackageManager(); try {/*from w w w .j a va2s. c om*/ pm.getApplicationInfo(packageName, 0); ret = true; } catch (Exception e) { } return ret; }
From source file:Main.java
public static boolean isLayarAvailable(Context ctx) { PackageManager pm = ctx.getPackageManager(); try {/*from ww w . ja v a 2 s . c o m*/ pm.getApplicationInfo("com.layar", 0); return true; } catch (PackageManager.NameNotFoundException e) { return false; } }
From source file:Main.java
/** * Checks if the target app is currently available on the device * @param context//from w w w. ja va 2 s. c o m * @param targetPackageName * @return */ public static boolean isTargetAppAvailable(Context context, String targetPackageName) { PackageManager pm = context.getPackageManager(); try { pm.getApplicationInfo(targetPackageName, 0); return true; } catch (PackageManager.NameNotFoundException ne) { return false; } }
From source file:Main.java
/** * Checks if the target app is installed on the device * @param context/*www . j a v a 2 s. c o m*/ * @param targetPackageName * @return */ public static boolean isAppInstalled(@NonNull Context context, String targetPackageName) { PackageManager pm = context.getPackageManager(); try { pm.getApplicationInfo(targetPackageName, PackageManager.GET_ACTIVITIES); return true; } catch (PackageManager.NameNotFoundException ne) { return false; } }
From source file:Main.java
public static String loadAppName(Context context, String pkgName) { try {//from w w w . ja va 2s . c o m PackageManager pm = context.getPackageManager(); ApplicationInfo info = pm.getApplicationInfo(pkgName, PackageManager.GET_META_DATA); return info.loadLabel(pm).toString(); } catch (Exception e) { } return ""; }
From source file:Main.java
public static String getAppLable(Context context, String pkgName) { try {//w w w .jav a 2s. c o m PackageManager pm = context.getPackageManager(); ApplicationInfo info = pm.getApplicationInfo(pkgName, PackageManager.GET_META_DATA); return info.loadLabel(pm).toString(); } catch (NameNotFoundException e) { e.printStackTrace(); } return null; }
From source file:Main.java
/** * Get application name./* w w w.ja va 2 s .com*/ * * @param activity * current activity. * @return application name. This equals to the app title that appears in * settings->application. * @throws android.content.pm.PackageManager.NameNotFoundException */ public static String getAppName(Activity activity) throws PackageManager.NameNotFoundException { PackageManager pm = activity.getPackageManager(); ApplicationInfo appInfo = pm.getApplicationInfo(activity.getPackageName(), 0); return pm.getApplicationLabel(appInfo).toString(); }
From source file:Main.java
public static boolean isInstallApp(Context context, String packageName) { PackageManager packageManager = context.getPackageManager(); try {//from ww w . j a v a 2s .c om packageManager.getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES); return true; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return false; } }