Location Permissions On Android 5.1
We have built and deployed a location-based shopping app that worked perfectly. That is until we discovered that our app does not work on Android 5.1.1 devices due to a Security Ex
Solution 1:
You can use the new ContextCompat
class and the method checkSelfPermission
for checking the permission before you execute the line of code that needed a check of permission.
public static boolean isPermissionGranted(String permission, Context context){
//int res = ContextCompat.checkSelfPermission(context, permission);
return (ContextCompat.checkSelfPermission(context, permission) == PackageManager.PERMISSION_GRANTED);
}
Now for permission for location you need to either check once if the user granted ACCESS_COARSE_LOCATION
or ACCESS_FINE_LOCATION
within your app.
Post a Comment for "Location Permissions On Android 5.1"