Get permission status when user has given runtime location access permission on Android

0

I'm picking up location data using LocationManager on Android and would like to know how I can get the action only if the user allows the app to access your data location.

For example, using the code below, I can pick up according to the user's positive permission, I need it before he accepts the permission to work on it later

However, I need to pick up the precise data in case the user has already allowed or not, to then work on that data regardless of whether he accepts it or not. Is it possible?

@Override
protected void onResume() {
    super.onResume();
    if (ContextCompat.checkSelfPermission(this,
            Manifest.permission.ACCESS_FINE_LOCATION)
            == PackageManager.PERMISSION_GRANTED) {
       //O que precisa fazer se a permissão for aceita.
    }
}
    
asked by anonymous 31.10.2018 / 00:51

1 answer

1

There are libraries that can help you with this task. This reduces the number of lines of code and makes your life easier and who will use your code later, if any.

My two favorites are: PermissionManager and Dexter

    
31.10.2018 / 13:56