Android Question A toddlers guide to Permissions

rodmcm

Active Member
Licensed User
Okay.So I understand that permissions are required by various functions but what I don't understand is where these are actually actioned
Recently I upgraded a Bluetooth program to SDK 33 and after its failure found suggestions from this forum that I had to add the following to the manifest file.
AddPermission(android.permission.ACCESS_FINE_LOCATION)
AddPermission(android.permission.BLUETOOTH_ADVERTISE)
AddPermission(android.permission.BLUETOOTH_CONNECT)
AddPermission(android.permission.BLUETOOTH_SCAN

This didnt work until I then added the following to my code


B4X:
    If phone.SdkVersion >= 31 Then
        Permissions = Array("android.permission.BLUETOOTH_SCAN", "android.permission.BLUETOOTH_CONNECT", rp.PERMISSION_ACCESS_FINE_LOCATION,rp.PERMISSION_ACCESS_COARSE_LOCATION)
    Else
        Permissions = Array(rp.PERMISSION_ACCESS_FINE_LOCATION)
    End If
    For Each per As String In Permissions
        rp.CheckAndRequest(per)
        Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
        If Result = False Then
            ToastMessageShow("No permission: " & Permission, True)
            Return
        End If
    Next

The permissions can also be listed from the IDE, This gives me the manifest list as well as these
Serial:
android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN


Bluetooth
android.permission.BLUETOOTH
android.permission.BLUETOOTH_ADMIN
android.permission. ACCESS_COARSE_LOCATION



So, A toddlers guide please. What does adding the permissions to the Manifest actually do? Why do I also have to add them into code?
Do the other permission listed come via the Serial and Bluetooth libraries?
 

DonManfred

Expert
Licensed User
Longtime User
 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
So, A toddlers guide please. What does adding the permissions to the Manifest actually do? Why do I also have to add them into code?
In the Manifest you declare which permissions your app will need to work.
Then in the code you make the effective request to the user to have such permissions granted.
 
Upvote 0

AnandGupta

Expert
Licensed User
Longtime User
Hi @rodmcm , we understand your point we also feel it is double work, but this is how Google made Android and also Play Console.
You will have to do twice/thrice similar work as Android was not built that way initially. It was all open, do whatever you want, system.
After law suits and many user problems due to this openness, Google now created 'layers' above the os. So you have to walk all these 'layers'.

This is my experience since Android version 3.0
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…