List of usage examples for android.content Context getPackageManager
public abstract PackageManager getPackageManager();
From source file:Main.java
public static ApplicationInfo getApplicationInfo(Context context, String pkg) { try {/*w w w.j a v a2 s. c om*/ return context.getPackageManager().getApplicationInfo(pkg, 0); } catch (NameNotFoundException e) { e.printStackTrace(); } return null; }
From source file:Main.java
public static String getVersionName(Context context) { try {/*w w w .ja v a2 s. co m*/ PackageInfo pkg = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pkg.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); return ""; } }
From source file:Main.java
public static String getAppVersion(Context context) { try {// w ww .j a v a 2 s. c om PackageInfo pInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); String version = pInfo.versionName; return version; } catch (PackageManager.NameNotFoundException e) { return null; } }
From source file:Main.java
public static String getAppVersionName(Context context) { try {/* w w w . j a v a 2 s .c o m*/ PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return info.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return "unkonwn"; }
From source file:Main.java
public static boolean isDebug(Context context) { PackageManager pm = context.getPackageManager(); try {/*from w ww . ja v a 2 s. c o m*/ ApplicationInfo applicationInfo = pm.getApplicationInfo(context.getPackageName(), 0); return (applicationInfo.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; } catch (NameNotFoundException e) { e.printStackTrace(); } return false; }
From source file:Main.java
public static boolean hasCameraAvailable(Context context) { try {/*from w w w.j a v a 2 s .c om*/ return context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA) || context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA_FRONT); } catch (Exception e) { return false; } }
From source file:Main.java
public static PackageInfo getPackageInfo(Context context) { PackageManager pm = context.getPackageManager(); try {/*from w w w .java2 s.c o m*/ return pm.getPackageInfo(context.getPackageName(), 0); } catch (Exception e) { return null; } }
From source file:Main.java
public static boolean isAppInstalled(Context context, String packageName) { try {//ww w .ja v a 2 s. c o m context.getPackageManager().getApplicationInfo(packageName, 0); return true; } catch (PackageManager.NameNotFoundException e) { return false; } }
From source file:Main.java
public static String getVersion(Context context) { try {/*from ww w . j a v a 2 s. c o m*/ PackageInfo manager = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return manager.versionName; } catch (PackageManager.NameNotFoundException e) { return "--"; } }
From source file:Main.java
public static String getAppVersionName(Context context) { try {/*from w w w . j a va 2s. co m*/ PackageManager pm = context.getPackageManager(); PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0); return pi.versionName; } catch (Exception e) { return ""; } }