How to set permission in AndroidManifest.xml for background location? - android

I know we should add "ACCESS_FINE_LOCATION" and "ACCESS_COARSE_LOCATION" permissions and for Android 10 and higher we should add "ACCESS_BACKGROUND_LOCATION".
But if my app is going to be published for all versions starting from android 7 to the latest android 12, how would my AndroidManifest file look like? should I add all the 3 above permissions together?

Adding (even unneccessary) permissions will not lead to crashes or bugs (at least as far as I know), so you can and should add those 3 permissions together, if you want to support that wide range of android versions

Related

Android 11 scoped storage permissions issue & how to use them properly?

I have a Cleaner app in java that has features like - System cleaner, Whatsapp manager, and Basic file Explorer to list & delete files i.e. downloads, images, videos, documents and audio.
Now it has to comply with Google's scoped storage enforcement or it will be removed from the store.
My question here is:
How to I make sure I am using correct permissions to comply with this policy? While making sure the older versions of Android would
still work as normally (or scoped storage api works with them too?).
What I have already done:
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="28" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
I have updated the permissions as shown above^ and set target sdk to 30, as well as removed requestLegacyExternalStorage flag from
manifest file.
Notice that WRITE_EXTERNAL_STORAGE is using max sdk = 28 tag, do I need to do this with other two (READ&WRITE) permissions also? (official doc only showed example of write-external-storage permission)
I'm still asking for these permissions in java code - do I need to wrap that code using if (Build.VERSION.SDK_INT < 30) to make sure
it's only asked in lower android versions or using the above tag in
manifest already takes care of that for me?
I have already implemented the requestDeletePermission() dialog for deleting files in Android 11 - it works! But for listing files in Basic explorer I'm
still using the old code that worked in old Android versions - do I
need to update that too? (Although it's still working with above 3 permissions)
Please help me I really have to finish it before the end of this month or my app will get removed. The whole point is to avoid violating the new policy in Android 11. I'm willing to give higher bounty to elaborative answers.
Thank you.

cordova : android 23 need "MODIFY_AUDIO_SETTINGS" permission at runtime

Im using WebRTC with cordova and I made the huge mistake of upgrading the version of android in the play store from 22 to 23. (apparently no way to revert this situation)
Now I must ask for the permissions at runtime. Everything is ok for now, but for WebRTC communication my app needs this particular permission "MODIFY_AUDIO_SETTINGS". For camera, microphone and location permissions I use cordova-diagnostic-plugin using those methods : requestCameraAuthorization, requestMicrophoneAuthorization and requestLocationAuthorization.
I tried requestRuntimePermission method with this as argument cordova.plugins.diagnostic.permission.MODIFY_AUDIO_SETTINGS but its not working since cordova.plugins.diagnostic.permission doesnt contain 'MODIFY_AUDIO_SETTINGS' permission. Here is the list of available permissions :
Im pretty much sur that the problem is the lack of 'MODIFY_AUDIO_SETTINGS' permission, since I had the same problem with android 22 (no audio) because I was not including it in the config. see this old SO post of mine
Thanks.
MODIFY_AUDIO_SETTINGS is not a "dangerous" permission that can be requested at run-time on Android: see here the full list of "dangerous" permissions which need to be requested at run-time.

permission state with API23 and old version

I set my gradle for min API 18 and Tagret API23.
I use the new permission system as need for API23 and also write all the require permission in the manifest as in the old days.
On Device use API23 it is work O.K.
But when I put the APK on device with 5.1.1 also it show me all the require permission during installation and i accept it, it is look that it doesn't get them in the application itself.
I also check in the application setting of this APK on the device and see all the permission are there (there is no checkbox so I assume if it is written it is enable).
Does the new permission system together with the old way (permission in manifest ) has to addapt automaticly to the device API level, or I need to make any check during the application runtime?
I figure it out by myself. For install the new APK I have to remove the older one completely. If I just go to the setting->Application found the app and delete it by “remove completely” it is not enough. I have to go to the actionBar on top in the same window and by the 3 buttons ask to “remove for all users”. Only then it doesn't have any trace and when I install the new APK it gets the right permission automatically.

Request permission on Android M only when targeting lower API

So in my app i would like to add an option to selectively add a permission (say, direct dial) when the user is on Android M but, at the same time, i would like to have that permission NOT showing as required in API 22 or lower simply because its not essential so i prefer not asking for it during install (so de facto making that feature available on M only).
So, i understand the new model of M is that it will allow optional permissions when user is on M and it will make those permissions mandatory when on lower APIs. So is there any known way to just remove those permissions on API lower than 23? Without having separate flavours / APK?
Maybe merging a manifest with just those lines when API is > 22 ? Or there is a cleaner solution?
This is possible. When reading the documentation there is a special flag to indicate for M only.
Use
<uses-permission-sdk23>
to apply permission for Marshmallow devices only.

Android minSdkVersion

I wrote a program that worked perfectly until the market required me to add 'minSdkVersion'. Since I was using 2.3.3 capabilities I set it at 10,but then my program stopped being able to access files from the disk (all file access is false though it works without 'minSdkVersion'). Changing it to require API 1 fixed the functionality but now inadequate OS versions can download it. Should the 'minSdkVersion' be able to change actual functionality? Any ideas what could cause this?
You should set minSdkVersion to the lowest adequate OS version for your app. Don't forget to also set targetSdkVersion to the highest level for which your app has been tested.
I'm going to assume when you say "access files" you mean on the SD card.
In this case, you need to add 2 new permissions:
<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"/>
These permissions weren't added until API level 4, so anything below that gets them for free.

Categories

Resources