List of usage examples for android.content Context getPackageManager
public abstract PackageManager getPackageManager();
From source file:Main.java
public static boolean isSupportCameraHardware(Context context) { if (context != null && context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_CAMERA)) { // this device has a camera return true; } else {//ww w . j a v a 2s .c o m // no camera on this device return false; } }
From source file:Main.java
/** * Checking for network support//from w ww . j ava 2 s . c o m * * @param ctx : context to be passed * @return : true is network support is available. */ public static final boolean hasNetworkSupport(Context ctx) { PackageManager packageManager = ctx.getPackageManager(); return (packageManager.hasSystemFeature(PackageManager.FEATURE_LOCATION_NETWORK)); }
From source file:Main.java
public static boolean isDebuggable(Context context) { PackageManager pm = context.getPackageManager(); try {// w w w . j a v a 2 s .c o m ApplicationInfo info = pm.getApplicationInfo(context.getPackageName(), 0); return (info.flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0; } catch (PackageManager.NameNotFoundException e) { } return true; }
From source file:Main.java
public static List<ResolveInfo> getBrowsers(Context context) { PackageManager pm = context.getPackageManager(); Intent query = new Intent(); query.setAction(Intent.ACTION_VIEW); query.setData(Uri.parse("http://localhost")); return pm.queryIntentActivities(query, 0); }
From source file:Main.java
public static void startApp(Context context, String packageName) { Intent intent = context.getPackageManager().getLaunchIntentForPackage(packageName); context.startActivity(intent);//w w w . j a v a 2 s . c o m }
From source file:Main.java
public static String getVersionName(Context context) { try {//from w w w . j a v a 2 s .c o m return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); } return "1.0.0"; }
From source file:Main.java
public static String getVersionName(Context context) { try {//w w w . ja v a 2 s . c o m return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName; } catch (NameNotFoundException e) { e.printStackTrace(); throw new RuntimeException("get versionCode Exception(RuntimeException)"); } }
From source file:Main.java
private static boolean isAppInstalled(String uri, Context context) { PackageManager pm = context.getPackageManager(); boolean installed = false; try {//w ww . j ava2 s . co m pm.getPackageInfo(uri, PackageManager.GET_ACTIVITIES); installed = true; } catch (PackageManager.NameNotFoundException e) { installed = false; } return installed; }
From source file:Main.java
private static int getLocalVersionCode(Context context) { try {//from w w w. ja v a2 s . com return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (PackageManager.NameNotFoundException e) { e.printStackTrace(); return -1; } }
From source file:Main.java
public static int getVersionCode(Context context) { try {/*from w w w .j a v a 2s . co m*/ return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode; } catch (NameNotFoundException e) { e.printStackTrace(); throw new RuntimeException("get versionCode Exception(RuntimeException)"); } }