List of usage examples for android.content Context getPackageManager
public abstract PackageManager getPackageManager();
From source file:Main.java
public static boolean intentIsAvailable(Context ctx, Intent intent) { final PackageManager mgr = ctx.getPackageManager(); List<ResolveInfo> list = mgr.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY); return list.size() > 0; }
From source file:Main.java
public static boolean appIsInstalled(Context context, String pageName) { try {/*from w ww .j a va 2 s. com*/ context.getPackageManager().getPackageInfo(pageName, 0); return true; } catch (NameNotFoundException e) { return false; } }
From source file:Main.java
public static String getPackagNameFromPath(Context context, String path) { PackageInfo pi = context.getPackageManager().getPackageArchiveInfo(path, 0); if (pi == null) { Log.e("null package:", "could not generate package info from path:" + path); return null; }/* ww w .j a v a2 s. com*/ return pi.packageName; }
From source file:Main.java
public static boolean apkInstalled(Context context, String uri) { PackageManager pm = context.getPackageManager(); try {//w w w . j a v a 2s .c o m pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); return true; } catch (PackageManager.NameNotFoundException e) { return false; } }
From source file:Main.java
public static void startApp(Context context, String packageName) { Intent LaunchIntent = context.getPackageManager().getLaunchIntentForPackage(packageName); context.startActivity(LaunchIntent); }
From source file:Main.java
public static String getVersionName(Context context) { try {/*from w w w .ja v a 2 s . c o m*/ PackageInfo pi = context.getPackageManager().getPackageInfo(context.getPackageName(), 0); return pi.versionName; } catch (NameNotFoundException e) { return null; } }
From source file:Main.java
/** * Check whether or not have camera feature. * * @param context/*from w ww .j a va2 s . co m*/ * * @return hasCamera */ public static boolean hasFeatureCamera(Context context) { boolean hasCamera = context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA); return hasCamera; }
From source file:Main.java
public static boolean isAppInstalled(Context ctx, String uri) { PackageManager pm = ctx.getPackageManager(); boolean installed = false; try {//from w w w . j av a 2s . co m pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); installed = true; } catch (PackageManager.NameNotFoundException e) { installed = false; } return installed; }
From source file:Main.java
public static boolean isCameraPresent(Context context) { boolean hasCamera = false; if (context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) { hasCamera = true;//from w w w .ja v a2s .co m } return hasCamera; }
From source file:Main.java
/** * Checks if this device supports SMS./* w w w. j a v a 2s . c om*/ * * @param context the Android context. * @return true if this device is SMS capable; false otherwise. */ public static boolean isSmsSupported(Context context) { PackageManager manager = context.getPackageManager(); if (manager.hasSystemFeature(PackageManager.FEATURE_TELEPHONY)) { return true; } return false; }