Since 8/2020 any new apps must set target SDK to 29, many changes Android developer need update, short solution is use
SetApplicationAttribute(android:requestLegacyExternalStorage, true)
but this is not good solution because in SDK 30 , this attribute will be bypass and will be error!!!
These are some issues i met when update app to targetSDK 29:
1. With old target SDK <29 we can use this code to add file to gallery https://www.b4x.com/android/forum/threads/show-image-in-gallery-android-7-0.97662/#content
But with new target SDK , this code can not work
(You can try with target SDK =29 and use file-provider https://www.b4x.com/android/forum/t...om-your-app-with-file-provider.70458/#content)
I search on Stackoverflow , their solution here :
https://stackoverflow.com/questions/57923329/save-and-insert-video-to-gallery-on-android-10
How can we implement this code to B4A?
2. And about File-provider
I think
should use
as default value, because this folder will be visible when use file manager app on Android 10, File.DirInternal will be invisible on phone without root, if we want to users can use files without using our app to open it!
Thank for reading , please suggestion any solutions for it!
SetApplicationAttribute(android:requestLegacyExternalStorage, true)
but this is not good solution because in SDK 30 , this attribute will be bypass and will be error!!!
These are some issues i met when update app to targetSDK 29:
1. With old target SDK <29 we can use this code to add file to gallery https://www.b4x.com/android/forum/threads/show-image-in-gallery-android-7-0.97662/#content
But with new target SDK , this code can not work
(You can try with target SDK =29 and use file-provider https://www.b4x.com/android/forum/t...om-your-app-with-file-provider.70458/#content)
I search on Stackoverflow , their solution here :
https://stackoverflow.com/questions/57923329/save-and-insert-video-to-gallery-on-android-10
How can we implement this code to B4A?
2. And about File-provider
B4X:
Public Sub Initialize
Dim p As Phone
If p.SdkVersion >= 24 Or File.ExternalWritable = False Then
UseFileProvider = True
SharedFolder = File.Combine(File.DirInternal, "shared")
File.MakeDir("", SharedFolder)
Else
UseFileProvider = False
SharedFolder = rp.GetSafeDirDefaultExternal("shared")
End If
Log($"Using FileProvider? ${UseFileProvider}"$)
End Sub
I think
B4X:
SharedFolder = File.Combine(File.DirInternal, "shared")
B4X:
SharedFolder = rp.GetSafeDirDefaultExternal("shared")
Thank for reading , please suggestion any solutions for it!