Hello, I have a problem.
When I execute my app with a phone that has got a android 9 version, it is all ok. But I tried to do the same with an older phone that has got a 5.0.1 android version, the app crash.
I only want to read a photo of the gallery and copy it in another directory to use it later.
It is a problem with permisission, but I do not know that I have to do. I have read a lot of threads but I do not get to it work. For example this one: https://www.b4x.com/android/forum/threads/runtime-permissions-android-6-0-permissions.67689/#content
My code is it:
My manifest editor has got it:
In attached image is the error.
I don not care where to copy the file, just that the file is available.
Please help. I think that it should be easy, but I haven't got what is happening.
When I execute my app with a phone that has got a android 9 version, it is all ok. But I tried to do the same with an older phone that has got a 5.0.1 android version, the app crash.
I only want to read a photo of the gallery and copy it in another directory to use it later.
It is a problem with permisission, but I do not know that I have to do. I have read a lot of threads but I do not get to it work. For example this one: https://www.b4x.com/android/forum/threads/runtime-permissions-android-6-0-permissions.67689/#content
My code is it:
B4X:
Sub EventoGaleriaFotos_Result (Success As Boolean, Dir As String, FileName As String)
Log("EventoGaleriaFotos_Result Success: " & Success)
dim imgsel as string
dim dirsel as string
If Success = True Then
Imgsel = FileName
DirSel = Dir
Private rp As RuntimePermissions
Dim ruta As String
ruta=rp.GetSafeDirDefaultExternal("temp")
If File.Exists(ruta,"ORIGINAL")=True Then
File.Delete(ruta,"ORIGINAL")
End If
File.Copy(DirSel,Imgsel,ruta,"ORIGINAL") ''-->CRASH
Else
Return ' no se seleccionó imagen
End If
End Sub
My manifest editor has got it:
B4X:
'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="9" android:targetSdkVersion="28"/>
<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)
'End of default text.
SetApplicationAttribute(android:usesCleartextTraffic, "true")
AddManifestText(<uses-permission
android:name="android.permission.WRITE_EXTERNAL_STORAGE"
android:maxSdkVersion="19" />
)
AddManifestText(<uses-permission
android:name="android.permission.READ_EXTERNAL_STORAGE"
android:maxSdkVersion="19" />
)
In attached image is the error.
I don not care where to copy the file, just that the file is available.
Please help. I think that it should be easy, but I haven't got what is happening.
Attachments
Last edited: