Android Question targetSdkVersion="33" and permissions

peacemaker

Expert
Licensed User
Longtime User
Hi, All

I have found that if targetSdkVersion is "33" - no PERMISSION_WRITE_EXTERNAL_STORAGE is shown in the app settings. And no request system dialog and Waiting For permission request is always with False result.
It's in B4xPages structure app, tested under Android 13 device and 2 emulators (Android 10).
B4A v.12.5, rp lib v.1.20.

Just changed into targetSdkVersion="32" - no problem with the dialog and app work.
Is it known ?
 
I'm making a picture gallery app using SimpleMediaManager and any local available photos. Without this permission no files gotten.
 
Upvote 0
SOLVED:
https://developer.android.com/reference/android/Manifest.permission
Note: Starting in API level 33, this permission has no effect. If your app accesses other apps' media files, request one or more of these permissions instead: READ_MEDIA_IMAGES, READ_MEDIA_VIDEO, READ_MEDIA_AUDIO. Learn more about the storage permissions that are associated with media files.
  1. [CODE lang="b4x" title="Manifest"]'This code will be applied to the manifest file during compilation.
    'You do not need to modify it in most cases.
    'See this link for for more information: https://www.b4x.com/forum/showthread.php?p=78136
    AddManifestText(
    <uses-sdk android:minSdkVersion="19" android:targetSdkVersion="33"/>
    <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.DarkTheme)
    'End of default text.

    AddManifestText(
    <uses-permission
    android:name="android.permission.WRITE_EXTERNAL_STORAGE"
    android:maxSdkVersion="19" />
    )

    AddManifestText(
    <uses-permission
    android:name="android.permission.READ_MEDIA_IMAGES"
    android:minSdkVersion="33" />
    )
    [/CODE]
  2. [CODE lang="b4x" title="B4XMainPage"]Private Sub B4XPage_Created (Root1 As B4XView)
    Dim ph As Phone 'phone lib
    If ph.SdkVersion = 33 Then
    rp.CheckAndRequest("android.permission.READ_MEDIA_IMAGES") 'rp = RuntimePermissions lib
    Else
    rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE)
    End If

    Wait For B4XPage_PermissionResult (Permission As String, Result As Boolean)
    If Result = True Then
    ....
    [/CODE]
 
Last edited:
Upvote 1
Back
Top