List of usage examples for android.content Context getPackageManager
public abstract PackageManager getPackageManager();
From source file:Main.java
public static void runApp(Context context, String packageName) { context.startActivity(new Intent(context.getPackageManager().getLaunchIntentForPackage(packageName))); }
From source file:Main.java
public static int getSize(Context context, Intent intent) { PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0); return activities.size(); }
From source file:Main.java
public static Boolean isAppInstalled(Context context, String appName) { PackageManager pm = context.getPackageManager(); boolean installed; try {//from w ww .j a v a2 s. c om pm.getPackageInfo(appName, PackageManager.GET_ACTIVITIES); installed = true; } catch (PackageManager.NameNotFoundException e) { installed = false; } return installed; }
From source file:Main.java
public static String getVersionInfo(Context context) { PackageManager packageManager = context.getPackageManager(); try {/* w w w .ja v a 2s .c o m*/ PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0); return packageInfo.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); Log.e("majunjun", "can't reach........"); return ""; } }
From source file:Main.java
public static boolean isGooglePlayInstalled(Context context) { PackageManager pm = context.getPackageManager(); boolean app_installed; try {//from www . j av a 2 s . c om PackageInfo info = pm.getPackageInfo("com.android.vending", PackageManager.GET_ACTIVITIES); String label = (String) info.applicationInfo.loadLabel(pm); app_installed = (label != null && label.equals("Google Play Store")); } catch (PackageManager.NameNotFoundException e) { app_installed = false; } return app_installed; }
From source file:Main.java
public static String getVersionName(Context context) { PackageManager packageManager = context.getPackageManager(); PackageInfo packageInfo = null;//w ww . java 2 s . c om try { packageInfo = packageManager.getPackageInfo(context.getPackageName(), 0); } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return null; } return packageInfo.versionName; }
From source file:Main.java
public static boolean doesPackageHaveSameSignature(Context context, String productPackage) { int compareSignatures = context.getPackageManager().checkSignatures(context.getPackageName(), productPackage);/*from w w w. ja va 2s . co m*/ return PackageManager.SIGNATURE_MATCH == compareSignatures; }
From source file:Main.java
public static boolean isInstalled(Context context, String packageName) { PackageManager pm = context.getPackageManager(); try {/*from w w w. j ava 2 s . c om*/ pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); return true; } catch (PackageManager.NameNotFoundException e) { return false; } }
From source file:Main.java
private static boolean isActionAvailable(Context context, Intent intent) { PackageManager packageManager = context.getPackageManager(); List<ResolveInfo> activities = packageManager.queryIntentActivities(intent, 0); return activities.size() > 0; }
From source file:Main.java
public static String getVersionName(Context context) { try {//from w w w. j av a 2s . c om PackageManager pm = context.getPackageManager(); PackageInfo info = pm.getPackageInfo(context.getPackageName(), 0); return info.versionName; } catch (Exception e) { e.printStackTrace(); } return ""; }