here is my code and it works perfectly fine.
if (ActivityCompat.checkSelfPermission(activity, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManag
You can rename your method as checkLocationPermission(Activity activity)
. I´ve discovered that your method's name must start with "check" and end with "Permission" to pass Lint warnings.
For example:
public static boolean checkLocationPermission(Context context) {
return ActivityCompat.checkSelfPermission(context,
Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(context,
Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
}