Example usage for android.content.pm PackageManager PERMISSION_GRANTED

List of usage examples for android.content.pm PackageManager PERMISSION_GRANTED

Introduction

In this page you can find the example usage for android.content.pm PackageManager PERMISSION_GRANTED.

Prototype

int PERMISSION_GRANTED

To view the source code for android.content.pm PackageManager PERMISSION_GRANTED.

Click Source Link

Document

Permission check result: this is returned by #checkPermission if the permission has been granted to the given package.

Usage

From source file:Main.java

public static boolean isGranted(int permissionCode) {
    return permissionCode == PackageManager.PERMISSION_GRANTED;
}

From source file:Main.java

private static boolean isGrant(int[] grantResults) {
    for (int grantResult : grantResults) {
        if (PackageManager.PERMISSION_GRANTED == grantResult) {
            return true;
        }//  w w  w  . j  av  a2s.  c o  m
    }
    return false;
}

From source file:Main.java

public static boolean checkPermission(Context context, String permission) {
    return (PackageManager.PERMISSION_GRANTED == context.checkCallingOrSelfPermission(permission));
}

From source file:Main.java

public static boolean verifyAllPermissions(int[] permissions) {
    for (int result : permissions) {
        if (result != PackageManager.PERMISSION_GRANTED) {
            return false;
        }/*from  w  w w .j ava2  s . c o  m*/
    }
    return true;
}

From source file:Main.java

private static boolean verifyPermissions(int[] grantResults) {
    for (int grantResult : grantResults) {
        if (grantResult != PackageManager.PERMISSION_GRANTED) {
            return false;
        }//from   w  ww. j a  va  2s.co  m
    }
    return true;
}

From source file:Main.java

private static boolean checkPermission(Context context, String p) {
    PackageManager pm = context.getPackageManager();
    return (PackageManager.PERMISSION_GRANTED == pm.checkPermission(p, context.getPackageName()));
}

From source file:Main.java

public static boolean hasPermission(Context context, String permission) {
    return context.checkCallingOrSelfPermission(permission) == PackageManager.PERMISSION_GRANTED;
}

From source file:Main.java

public static boolean isBlePermission(Context context) {
    PackageManager pm = context.getPackageManager();
    boolean permission = (PackageManager.PERMISSION_GRANTED == pm
            .checkPermission("android.permission.BLUETOOTH", context.getPackageName()));
    return permission;
}

From source file:Main.java

public static boolean getPermission(String permission, Context context) {
    PackageManager pm = context.getPackageManager();
    return PackageManager.PERMISSION_GRANTED == pm.checkPermission(permission, "com.example.renrenstep");
}

From source file:Main.java

public static boolean hasPermission(Context context, String permissionStr) {
    PackageManager pm = context.getPackageManager();
    boolean permission = (PackageManager.PERMISSION_GRANTED == pm.checkPermission(permissionStr,
            context.getPackageName()));//  w  ww  .j  av  a 2  s.  c  om
    return permission;
}