In Android 10, when asking for some permission like Location, the system prompts the user 3 options:
Allow APP to access this device's location?
-Allow all the time
-Allow only while using the app
-Deny
Is there a way to know how exactly has been granted? I use this code to know if location is granted:
boolean hasPermission = (ContextCompat.checkSelfPermission(oContext, Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED);
But I need to know if it has been granted "all the time" or just "while using the app". What I really need is to have permission all the time as my app has a background location service. So I need to know if the permission has been granted to to that, or the possibility to ask for the permission but without the option of allowing it "only when using the app".
requestPermissions(Context, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, 123);