private boolean checkPermission(String permission) {
        int res = ctx.checkCallingOrSelfPermission(permission);
        return (res == PackageManager.PERMISSION_GRANTED);
    }
private boolean checkPermission ( String permission ) { int res = ctx . checkCallingOrSelfPermission ( permission ) ; return ( res == PackageManager . PERMISSION_GRANTED ) ; }
Check whether the application has been granted a certain permission.

@param permission Permission as a string
@return true if permissions is granted