Android Question location permissions in Android 14 (sdk34)

Yanik Freeman

Member
Licensed User
Hi there,

I used the code from this thread to prompt to enable location permissions in earlier versions of Android with no issues:


I have a client with a Galaxy S21 who is reporting that they had to manually enable location permissions through the system menus for the app, does anyone know if this has to be done differently for this version of Android?

Not having access to an Android 14 device to test is it currently possible to emulate that environment using the B4A AVD?

Thanks!
 

drgottjr

Expert
Licensed User
Longtime User
not only do you need fineaccess permission in the manifest, but you will have to direct the user to the locations settings dialog on his device if location is turned off, even though the user has granted you permission to use location (it's a runtime permission).
you cannot turn on location from the app, but you can check if location is on. so you get permission from user for your app to use location, then you check to see if location is on. if it's not on, you tell user he needs to turn location on and you can ask if he would like to do that now. if he says, yes, you:
B4X:
            Dim intent As Intent
            intent.Initialize("android.settings.LOCATION_SOURCE_SETTINGS","")
            StartActivityForResult( intent )
when he turns location on, the os signals your app, and you're good to go.

this procedure is in effect for other types of system settings that cannot be enabled from an application.
 
Upvote 0
Top