List of usage examples for android.content Context getPackageManager
public abstract PackageManager getPackageManager();
From source file:Main.java
private static int getAppVersion(Context context) { try {/*w w w .ja v a2s . co m*/ PackageManager pm = context.getPackageManager(); PackageInfo packageInfo = pm.getPackageInfo(context.getPackageName(), 0); return packageInfo.versionCode; } catch (PackageManager.NameNotFoundException e) { throw new RuntimeException(e); } }
From source file:Main.java
public static String getAppVersionNameString(Context ctx, String packageName) { List<PackageInfo> pkgs = ctx.getPackageManager().getInstalledPackages(0); for (PackageInfo pi : pkgs) { if (pi.packageName.equals(packageName)) { return pi.versionName; }//from w w w . j av a2 s .c om } return null; }
From source file:Main.java
public static void lunchTheApp(String pack, Context context) { try {/*www .j ava 2 s .co m*/ Intent LaunchIntent = context.getPackageManager().getLaunchIntentForPackage(pack); context.startActivity(LaunchIntent); } catch (ActivityNotFoundException e) { } catch (Exception e) { //NULL pointer for context } }
From source file:Main.java
public static boolean isThemeAppEnabled(Context context) { PackageManager pm = context.getPackageManager(); try {/*from w ww. j a va 2s . com*/ ApplicationInfo info = pm.getApplicationInfo(THEME_APP_PACKAGE_NAME, 0); return info.enabled; } catch (PackageManager.NameNotFoundException e) { Log.w(TAG, "isThemeAppEnabled E=" + e); return false; } }
From source file:Main.java
public static int getAppVersion(Context context) { try {//from w ww . j a v a2s .com PackageInfo info = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return info.versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); } return 1; }
From source file:Main.java
public static boolean isSlydepayPresent(Context context) { final PackageManager packageManager = context.getPackageManager(); Intent intent = packageManager.getLaunchIntentForPackage("com.dreamoval.slydepay.android.cruise"); if (intent == null) { return false; }/*from w w w.ja v a 2 s .co m*/ List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:Main.java
public static void startAppByPackageName(Context context, String s) { new Intent(); context.startActivity(context.getPackageManager().getLaunchIntentForPackage(s)); }
From source file:Main.java
public static String getAppVersionName(Context c) { try {/*from ww w . j a v a 2 s . c o m*/ PackageManager manager = c.getPackageManager(); PackageInfo info = manager.getPackageInfo(c.getPackageName(), 0); return info.versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } return "v1.0.0.1"; }
From source file:Main.java
public static boolean intentAvailable(Context context, Intent intent) { PackageManager packageManager = context.getPackageManager(); List list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:Main.java
public static String getAppPkg(Context c, int uid) throws NullPointerException { PackageManager pm = c.getPackageManager(); String name = pm.getPackagesForUid(uid)[0]; return name;/* w w w. ja v a 2 s.c o m*/ }