Android Question [Solved] Bug in my application (on the same device) if I change only targetSDK

bernardR

Member
Licensed User
Hello,
I have an application no-google running on Android 10 with minSdkVersion=29 and targetSdkVersion=29.
If I put targetSdkVersion = 30, it no longer works on the same Android 10 device.
Why ?
Is this an issue with AppCompat?

Here are some details:
B4A version=11.20
platform SDK=30
used device: Redmi 8 with Android 10
SetApplicationAttribute(android:requestLegacyExternalStorage, true) in manifest
PERMISSION_WRITE_EXTERNAL_STORAGE=true

Here is the buggy code:

B4X:
Sub Process_Globals
    Private ApiAndroid As Int
End Sub

Sub Globals
    Private wv As WebView
End Sub

Sub Activity_Create(FirstTime As Boolean)
    wv.Initialize("wv")
    Activity.AddView(wv,0,0,100%x,100%y)
    wv.Color=Colors.White
    wv.Visible=True
 
    Dim r As Reflector
    ApiAndroid=r.GetStaticField("android.os.Build$VERSION","SDK_INT")

    Dim rp As RuntimePermissions
    Log("ApiAndroid=" & ApiAndroid & " : Requesting WRITE_EXTERNAL_STORAGE permission")
    rp.CheckAndRequest(rp.PERMISSION_WRITE_EXTERNAL_STORAGE) ' Implicit read capability if granted

    Wait For Activity_PermissionResult (Permission As String, Result As Boolean)
    Log($"${Permission} = ${Result}"$)

    Dim mystorage As String="/storage/emulated/0"
    Dim txtHtml As String=$"<img src="${mystorage}/mydir/1.jpg"/>"$
    wv.LoadHtml(txtHtml)
    Log(txtHtml)
End Sub

Internal storage name: storage/emulated/0
Folder at the root of internal memory: /mydir
picture in /mydir: 1.jpg

Purpose: display an image
Bug:
The 1.jpg image is displayed on my Redmi with targetSdkVersion = 29
It is not displayed on the same device if targetSdkVersion = 30

I have isolated the problem below in a small app

Thank-you for your help
 
Last edited:

agraham

Expert
Licensed User
Longtime User
No, it's a change in permissions with targeting SDK30. See here
If it's not to go in the Play Store see here
Otherwise see here
 
Upvote 1

bernardR

Member
Licensed User
I use your class ManageExternalStorage if apiAndroid=30; but ManageExternalStorage works on android 11, but not on android 10.
I wish my app to work on android 10 and android 11.
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
I wish my app to work on android 10 and android 11.
Sorry but I don't know how to do that. My own apps, that are not for the Play Store, either target SDK 28 to run on Android 10 and 11 or target SDK 30 and use ManageExternalStorage to run on Android 11 only/
 
Upvote 0

bernardR

Member
Licensed User
Sorry but I don't know how to do that. My own apps, that are not for the Play Store, either target SDK 28 to run on Android 10 and 11 or target SDK 30 and use ManageExternalStorage to run on Android 11 only/
If you use target SDK 28, can you read un external storage on device android 11 ?
 
Upvote 0
Top