-3

I have created an app which amongs others show the SSID name. Now with the latest android version, the user needs to set extra permissions (<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />) for my app to be able to get the SSID name.

Now that's all fine, but 1. these permissions are harder to get (I understand that I can't just ask for them but the user has to explicit go to the app-settings and accept the location permission) and, more importantly 2. I don't want to ask for those rights if the user is still on an old(er) version of Android and these extra permissions are not needed.

I have these settings

minSdkVersion 11
targetSdkVersion 26

so also very old Android versions can install my app, and now they also have to give the permission for the Android version they don't yet have?

I would like that only users on the latest version of Android have to give these permission, and users on older Android versions don't have to.

Is it possible to make this distinction in the manifest?

I've seen a reference to Is it available to set checkSelfPermission on minimum SDK < 23? but that question doesn't talk about the manifest xml and that's what my question is about

Michel
  • 23,085
  • 46
  • 152
  • 242

1 Answers1

1

User won't have to go explicit to the app-settings, just check the Android version with

android.os.Build.VERSION.SDK_INT >= N

And if it is true, you should ask the permission with

Activity.requestPermissions(String[] permissions, int requestCode)

Then listen the result with Activity.onPermissionsResult.

Jose Riballo
  • 308
  • 2
  • 12
  • And should I then just leave it in the manifest.xml? Because I thought that all the permissions in the manifest.xml are asked for to the user when he/she installs the app, so then also the users which are using an older version are asked for these permissions? – Michel Mar 26 '19 at 16:04
  • Yes, you should just leave in the manifest.xml. It doesn't mean app will ask this permission, just it can request the permission when needed. – Jose Riballo Mar 27 '19 at 07:42