List of usage examples for android.content.pm PackageManager GET_ACTIVITIES
int GET_ACTIVITIES
To view the source code for android.content.pm PackageManager GET_ACTIVITIES.
Click Source Link
From source file:Main.java
/** * Checks if the target app is installed on the device * @param context// w ww . j av a 2s .c om * @param targetPackageName * @return */ public static boolean isAppInstalled(@NonNull Context context, String targetPackageName) { PackageManager pm = context.getPackageManager(); try { pm.getApplicationInfo(targetPackageName, PackageManager.GET_ACTIVITIES); return true; } catch (PackageManager.NameNotFoundException ne) { return false; } }
From source file:Main.java
private static boolean appInstalledOrNot(String uri, Context context) { PackageManager pm = context.getPackageManager(); boolean app_installed; try {//w w w.ja v a 2 s. c o m pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); app_installed = true; } catch (PackageManager.NameNotFoundException e) { app_installed = false; } return app_installed; }
From source file:Main.java
/** * Checks if an App is Installed./*from w ww . j a va2 s . c o m*/ * * @return true if installed false otherwise */ public static boolean isAppInstalled(Context context, String packageName) { if (context == null) return false; PackageManager pm = context.getApplicationContext().getPackageManager(); boolean isAppInstalled = false; try { pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); isAppInstalled = true; } catch (PackageManager.NameNotFoundException e) { isAppInstalled = false; } return isAppInstalled; }
From source file:Main.java
/** * get UnInstallApkPackageName/* w ww . j a v a 2 s. c om*/ * * @param context Context * @param apkPath apkPath * @return apk PackageName */ public static String getUnInstallApkPackageName(Context context, String apkPath) { PackageManager pm = context.getPackageManager(); PackageInfo info = pm.getPackageArchiveInfo(apkPath, PackageManager.GET_ACTIVITIES); if (info != null) { ApplicationInfo appInfo = info.applicationInfo; if (appInfo != null) { return appInfo.packageName; } } return null; }
From source file:Main.java
public static String getVersionName(final Context context) { PackageManager packageManager = context.getPackageManager(); try {// w ww .ja v a 2 s . com PackageInfo packageInfo = packageManager.getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES); return packageInfo.versionName; } catch (NameNotFoundException e) { return "Unknown"; } }
From source file:Main.java
/** * Check if BerryMotes app is installed * //from w w w. ja v a 2 s. c o m * @param context Android context * @return true if BerryMotes is installed */ public static boolean isBerryMotesInstalled(Context context) { PackageManager pm = context.getPackageManager(); try { pm.getPackageInfo(BERRYMOTES_NAME, PackageManager.GET_ACTIVITIES); return true; } catch (PackageManager.NameNotFoundException e) { return false; } }
From source file:Main.java
/** * Check if the specified application is installed. * * @param context/* w w w .j a v a 2 s . c o m*/ * application context * @param packageName * package name of the application to test * @return Return true if the specified app is installed */ public static boolean isAppInstalled(Context context, String packageName) { final PackageManager pm = context.getPackageManager(); boolean installed = false; try { pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); installed = true; } catch (final PackageManager.NameNotFoundException e) { installed = false; } return installed; }
From source file:Main.java
/** * Check if package installed/*from www.ja va2 s . c o m*/ * * @param context Context of current app * @param uri Package of application to check * @return true if passed package installed */ public static boolean isAppInstalled(Context context, String uri) { PackageManager pm = context.getPackageManager(); boolean appInstalled; try { assert pm != null; pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); appInstalled = true; } catch (PackageManager.NameNotFoundException e) { appInstalled = false; } return appInstalled; }
From source file:Main.java
/** * Returns the version name of the current app * * @param context an app context to retrieve the package manager and package name * @return the version name or "unknown" if the package name (of this current app) is not found *///from w w w.j av a 2 s .c o m public static String getVersionName(Context context) { String versionName = "unknown"; try { versionName = context.getPackageManager().getPackageInfo(context.getPackageName(), PackageManager.GET_ACTIVITIES).versionName; } catch (PackageManager.NameNotFoundException ignore) { Log.d("NoTils", "Version name not found, Paul has a hat to eat.", ignore); } return versionName; }
From source file:Main.java
public static boolean isActivityInstalled(Context context, String packageName, String activityName) { if (packageName == null || packageName.trim().length() == 0) { return false; }/* www . j a v a2 s . co m*/ if (activityName == null || activityName.trim().length() == 0) { return false; } try { PackageManager pm = context.getPackageManager(); PackageInfo pi = pm.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES); String s = packageName + activityName; for (int i = 0; i < pi.activities.length; i++) { ActivityInfo ai = pi.activities[i]; if (ai.name.equals(s)) { return true; } } } catch (Exception e) { } return false; }