List of usage examples for android.content.pm PackageManager PERMISSION_GRANTED
int PERMISSION_GRANTED
To view the source code for android.content.pm PackageManager PERMISSION_GRANTED.
Click Source Link
From source file:Main.java
public static boolean checkPermission(Context context, String permName, String pkgName) { PackageManager pm = context.getPackageManager(); if (PackageManager.PERMISSION_GRANTED == pm.checkPermission(permName, pkgName)) { // System.out.println(pkgName + "has permission : " + permName); return true; } else {/*ww w . j a v a2 s. co m*/ //PackageManager.PERMISSION_DENIED == pm.checkPermission(permName, pkgName) // System.out.println(pkgName + "not has permission : " + permName); return false; } }
From source file:Main.java
/** * Gets record audio permission./* w ww . j a v a 2 s .c om*/ * * @return the record audio permission */ public static boolean getRecordAudioPermission() { return PackageManager.PERMISSION_GRANTED == mContext.getPackageManager() .checkPermission("android.permission.RECORD_AUDIO", getAppPackageName()); }
From source file:Main.java
static boolean hasPermission(Context context, String permission) { return (context.getPackageManager().checkPermission(permission, context.getPackageName()) == PackageManager.PERMISSION_GRANTED); }
From source file:Main.java
public static boolean checkPermission(Context context) { return context.checkPermission(Manifest.permission.CAMERA, Process.myPid(), Process.myUid()) == PackageManager.PERMISSION_GRANTED; }
From source file:Main.java
private static boolean haveReadLogsPermission(Context context) { return context.getPackageManager().checkPermission("android.permission.READ_LOGS", context.getPackageName()) == PackageManager.PERMISSION_GRANTED; }
From source file:Main.java
public static boolean checkedPermission(Context context, String permission) { boolean rs = false; try {//from w w w . ja v a 2s . c o m rs = (context.checkCallingOrSelfPermission( android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED); } catch (Exception e) { e.printStackTrace(); return false; } return rs; }
From source file:Main.java
public static boolean hasExternalStoragePermission(Context context) { int perm = context.checkCallingOrSelfPermission(EXTERNAL_STORAGE_PERMISSION); return perm == PackageManager.PERMISSION_GRANTED; }
From source file:Main.java
protected static boolean hasExternalStoragePermission(Context context) { int perm = context.checkCallingOrSelfPermission(EXTERNAL_STORAGE_PERMISSION); return perm == PackageManager.PERMISSION_GRANTED; }
From source file:Main.java
private static boolean hasExternalStoragePermission(Context context) { int permission = context.checkCallingPermission(EXTERNAL_STORAGE_PERMISSION); return permission == PackageManager.PERMISSION_GRANTED; }
From source file:Main.java
/** * @param context//from w w w .ja va2s. c o m * @return true if the device has an internet connection */ public final static boolean hasInternetConnection(Context context) { if (PackageManager.PERMISSION_GRANTED == context .checkCallingOrSelfPermission(Manifest.permission.ACCESS_NETWORK_STATE)) { final ConnectivityManager connManager = (ConnectivityManager) context .getSystemService(Context.CONNECTIVITY_SERVICE); final NetworkInfo networkInfo = connManager.getActiveNetworkInfo(); if (networkInfo != null) { return networkInfo.isConnected(); } } return false; }