List of usage examples for android.app Activity getPackageManager
@Override
public PackageManager getPackageManager()
From source file:Main.java
public static String getVersionName(Activity activity) { PackageManager packageManager = activity.getPackageManager(); PackageInfo packInfo;// w ww.j a v a 2s.c om try { packInfo = packageManager.getPackageInfo(activity.getPackageName(), 0); return packInfo.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return "1.0"; } }
From source file:Main.java
public static int getVersionCode(Activity activity) { try {//w ww . j a v a2 s . c o m PackageInfo info = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0); return info.versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return 0; } }
From source file:Main.java
public static String getVersion(Activity activity) { try {//www. j ava 2 s .co m PackageInfo pInfo = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0); return pInfo.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return "0"; } }
From source file:Main.java
public static String getVersionName(Activity activity) { try {/*from w w w . ja va 2 s. c om*/ PackageInfo info = activity.getPackageManager().getPackageInfo(activity.getPackageName(), 0); return info.versionName; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return ""; } }
From source file:Main.java
public static int getVersionCode(Activity context) { PackageManager packageManager = context.getPackageManager(); PackageInfo packInfo = null;//from w w w . ja v a 2 s .co m try { packInfo = packageManager.getPackageInfo(context.getPackageName(), 0); } catch (NameNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (packInfo != null) { return packInfo.versionCode; } return 0; }
From source file:Main.java
public static void call(Activity activity, String packageName) { Intent intent = activity.getPackageManager().getLaunchIntentForPackage(packageName); if (null != intent) { activity.startActivity(intent);/*from w w w . j a v a2s .co m*/ } }
From source file:Main.java
public static void launch(Activity activity, String package_name) throws Exception { Intent intent = activity.getPackageManager().getLaunchIntentForPackage(package_name); if (intent != null) activity.startActivity(intent);/*www . jav a 2 s . c o m*/ else throw new Exception("Package Not Found"); }
From source file:Main.java
public static boolean hasInstalledWx(Activity activity) { try {// ww w. j a v a 2 s. c o m PackageManager manager = activity.getPackageManager(); PackageInfo info = manager.getPackageInfo(WX_PACKAGE_NAME, PackageManager.GET_ACTIVITIES); if (info != null) { return true; } } catch (Exception e) { e.printStackTrace(); } return false; }
From source file:Main.java
private static boolean isCameraActivityAvailable(Activity currentActivity, Intent takePictureIntent) { return takePictureIntent.resolveActivity(currentActivity.getPackageManager()) != null; }
From source file:Main.java
public static String getMeta(Activity context, String key) throws PackageManager.NameNotFoundException { ActivityInfo info = context.getPackageManager().getActivityInfo(context.getComponentName(), PackageManager.GET_META_DATA); String value = info.metaData.getString(key); return value; }