I'm trying to get the current location from either GPS or from network provider for which I'm using these permissions by declaring it in AndroidManifest.xml,
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
I'm validating the permission at runtime as,
ActivityCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED)
and
ActivityCompat.checkSelfPermission(context, android.Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED
It works fine for me with Android SDK version 22 whereas in SDK version 25 though the permission is declared within AndroidManifest.xml it's not getting reflected at runtime.
I checked whether these permissions are granted or not by,
adb shell dumpsys package com.abc.xyz
The permissions were not granted for my app which runs on SDK-25 when I tried to grant the permission with adb shell as,
adb shell pm grant com.abc.xyz android.Manifest.permission.ACCESS_COARSE_LOCATION
I'm suspecting Android made these permissions to be granted from SDK version 25 (Please correct me If I'm wrong). With just googling I'm not able to figure out how the permission level/severity changed between SDK Versions.
Please help me know about it.
On all versions of Android, your app needs to declare both the normal and the dangerous permissions it needs in its app manifest, as described in Declaring Permissions. However, the effect of that declaration is different depending on the system version and your app's target SDK level:
If your app's target SDK is 22 or lower: If you list a dangerous permission in your
manifest, the user has to grant the permission when they install the
app; if they do not grant the permission, the system does not install the app at all.
If your app's target SDK is 23 or higher: The app has to list the permissions in the manifest, and it must request each dangerous permission it needs while the app is running. The user can grant or deny each permission, and the app can continue to run with limited
capabilities even if the user denies a permission request.
you can refer to this Link