Android Context Check isPermissionGranted(Context ctx)

Here you can find the source of isPermissionGranted(Context ctx)

Description

Check BATTERY_STATS permission.

License

Apache License

Parameter

Parameter Description
ctx a parameter

Return

true if BATTERY_STATS is granted.

Declaration

public static boolean isPermissionGranted(Context ctx) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import android.content.Context;
import android.content.pm.PackageManager;

public class Main {
    /**//from ww w  . jav a 2  s . c  om
     * Check BATTERY_STATS permission.
     *
     * @param ctx
     * @return true if BATTERY_STATS is granted.
     */
    public static boolean isPermissionGranted(Context ctx) {
        PackageManager pm = ctx.getPackageManager();
        int perm = pm.checkPermission(
                android.Manifest.permission.BATTERY_STATS,
                ctx.getPackageName());
        return (perm == PackageManager.PERMISSION_GRANTED);
    }
}

Related

  1. isOnline(Context c)
  2. isOnline(Context context)
  3. isOnline(Context context)
  4. isOnline(Context context)
  5. isOnline(Context context)
  6. isSensAppInstalled(Context context)
  7. isServiceRunning(Context ctx, String className)
  8. isServiceRunning(Context ctx, String className)
  9. isSystemApplication(Context context, String packageName)