List of usage examples for android.content Context getPackageManager
public abstract PackageManager getPackageManager();
From source file:Main.java
public static int getVersionCode(Context context) { PackageManager pm = context.getPackageManager(); try {/*from w w w . j av a 2 s.com*/ PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), 0); return packageInfo.versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return 0; } }
From source file:Main.java
public static int getCurrVersion(Context context) { PackageManager pm = context.getPackageManager(); try {/*from w ww. j av a 2 s . c o m*/ PackageInfo info = pm.getPackageInfo(context.getPackageName(), 0); return info.versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return 0; }
From source file:Main.java
public static CharSequence getApplicationName(Context context) { PackageManager packageManager = context.getPackageManager(); return context.getApplicationInfo().loadLabel(packageManager); }
From source file:Main.java
public static boolean isLayarAvailable(Context ctx) { PackageManager pm = ctx.getPackageManager(); try {//from w ww . j av a 2 s . c o m pm.getApplicationInfo("com.layar", 0); return true; } catch (PackageManager.NameNotFoundException e) { return false; } }
From source file:Main.java
public static String getApplicationVersion(Context ctx) { try {/*from w w w.ja v a 2s. c o m*/ return ctx.getPackageManager().getPackageInfo(ctx.getPackageName(), 0).versionName; } catch (PackageManager.NameNotFoundException e) { Log.d(TAG, "", e); return null; } }
From source file:Main.java
public static int getVersionCode(Context context) { try {//from w w w . j a v a2 s. com return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); } return -1; }
From source file:Main.java
private static boolean hasImplicitIntent(Context paramContext, Intent paramIntent) { if (paramContext.getPackageManager().queryIntentActivities(paramIntent, 65536).size() > 0) { }//from w ww . j a va2 s .co m for (boolean bool = true;; bool = false) { return bool; } }
From source file:Main.java
private static int getVersionCode(Context context) { try {//from ww w. j a va 2 s . c o m return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { return -1; } }
From source file:Main.java
/** * Checks if app given by package name is installed on device. * /*from ww w .j a v a2s .c om*/ * @param packageName * The package name where the app should be found * @return true if app is installed on device. false if not. */ public static boolean isInstalled(String packageName, Context ctx) { PackageManager pm = ctx.getPackageManager(); try { pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); return true; } catch (PackageManager.NameNotFoundException e) { return false; } }
From source file:Main.java
public static boolean isCameraUseAble(Context context) { PackageManager packageManager = context.getPackageManager(); return packageManager.hasSystemFeature(PackageManager.FEATURE_CAMERA); }