Android Question RuntimePermissions

Sergey_New

Well-Known Member
Licensed User
Longtime User
When using RuntimePermissions, permission cannot be obtained:
B4X:
AddManifestText(
<uses-sdk android:minSdkVersion="21" android:targetSdkVersion="29"/>
<supports-screens android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="true"
    android:anyDensity="true"/>)
SetApplicationAttribute(android:icon, "@drawable/icon")
SetApplicationAttribute(android:label, "$LABEL$")
CreateResourceFromFile(Macro, Themes.LightTheme)
'AddPermission(android.permission.WRITE_EXTERNAL_STORAGE)
AddManifestText(
<uses-permission
  android:name="android.permission.WRITE_EXTERNAL_STORAGE"
  android:maxSdkVersion="29" />
)
B4X:
Sub Process_Globals
    Private xui As XUI
    Private rp As RuntimePermissions
End Sub

Sub Globals
    
End Sub

Sub Activity_Create(FirstTime As Boolean)
    Activity.LoadLayout("Layout")
    Check
End Sub

Sub Check
    rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    If Result Then
        Log(Permission)
    End If
End Sub
Tested on a Samsung Galaxy S23 FE with Android 14 and on an emulator with Android 13.
Result = False
 

agraham

Expert
Licensed User
Longtime User
That is correct, PERMISSION_WRITE_EXTERNAL_STORAGE doesn't work for target SDK >28. Check these posts.

 
Upvote 0

Sagenut

Expert
Licensed User
Longtime User
What you need to do exactly?
Maybe it's not needed to request for that permission or other.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
We already showed that you have to use ExternalStorage Class if you want to use a targetSDK higher than 28.

Fully ignoring the suggestions and just try again is of no help here.
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
Last edited:
Upvote 0
Top