List of usage examples for android.content Context getPackageManager
public abstract PackageManager getPackageManager();
From source file:Main.java
private static PackageInfo getPackageInfo(Context context, int flags) throws NameNotFoundException { return context.getPackageManager().getPackageInfo(context.getPackageName(), flags); }
From source file:Main.java
public static void openApp(Context paramContext, String paramString) { paramContext.startActivity(paramContext.getPackageManager().getLaunchIntentForPackage(paramString)); }
From source file:Main.java
public static String getAppVersionName(Context context) { PackageManager pm = context.getPackageManager(); PackageInfo pi;//from ww w.j a v a 2 s . co m try { pi = pm.getPackageInfo(context.getPackageName(), 0); return pi.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return ""; }
From source file:Main.java
public static String getAppName(Context context) { PackageManager packageManager = context.getPackageManager(); ApplicationInfo appInfo = null;/*www . ja v a 2 s . c om*/ try { appInfo = packageManager.getApplicationInfo(context.getPackageName(), 0); } catch (NameNotFoundException e) { } return appInfo == null ? "null" : packageManager.getApplicationLabel(appInfo).toString(); }
From source file:Main.java
public static int getVersion(Context context) { try {/*from w w w. j av a 2s . co m*/ PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pInfo.versionCode; } catch (PackageManager.NameNotFoundException ex) { ex.printStackTrace(); } return 0; }
From source file:Main.java
public static String getVersionName(Context context) { try {/* w w w. j a v a 2s. co m*/ PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return info.versionName; } catch (NameNotFoundException e) { return ""; } }
From source file:Main.java
public static String getApplicationVersion(String packageName, Context context) { PackageManager packageManager = context.getPackageManager(); PackageInfo packageInfo = null;/*from w w w .j a v a 2 s . com*/ try { packageInfo = packageManager.getPackageInfo(packageName, PackageManager.GET_META_DATA); return packageInfo.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public final static boolean isPackageInstalled(Context context, String packageName) { try {/* w ww . j a v a2 s .c om*/ context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); } catch (NameNotFoundException e) { return false; } return true; }
From source file:Main.java
public static boolean isAppInstalled(Context context, String packageName) { try {/*from w ww .ja v a2 s. com*/ context.getPackageManager().getPackageInfo(packageName, 0); return true; } catch (PackageManager.NameNotFoundException e) { return false; } }
From source file:Main.java
/** * Check whether or not have auto-focus feature. * * @param context/*from w w w . ja v a 2 s .c o m*/ * * @return hasAutoFocus */ public static boolean hasFeatureAutoFocus(Context context) { boolean hasAutoFocus = context.getPackageManager() .hasSystemFeature(PackageManager.FEATURE_CAMERA_AUTOFOCUS); return hasAutoFocus; }