Here you can find the source of isPermissionGranted(Context ctx)
Parameter | Description |
---|---|
ctx | a parameter |
public static boolean isPermissionGranted(Context ctx)
//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); } }