With android 11 and sdk 30 the download of the file does not work ..
this is my code:
The error is in the permissions to access the download folder .. How can I solve?
thank you.
this is my code:
B4X:
Sub GetDownloadLink(link As String)
Log("link:")
Log(link)
If link <> "" And link.StartsWith("http") Then
Dim j As HttpJob
j.Initialize("",Me)
j.Download(link)
ProgressDialogShow2("Downloading...",False)
Wait For (j) JobDone(j As HttpJob)
ProgressDialogHide
If j.Success Then
Dim filename As String = j.Response.GetHeaders.Get("content-disposition")
Log(filename)
If filename.IndexOf("filename=") <> -1 Then
filename = filename.SubString2(filename.IndexOf("filename=")+9,filename.Length-1)
Starter.nomefile = filename
Dim os As OutputStream
os = File.OpenOutput(File.DirRootExternal & "/Download",filename,False)
File.Copy2(j.GetInputStream,os)
os.Close
Dim ext As String
ext = filename.SubString2(filename.LastIndexof("."), filename.Length)
Log("Estensione file:")
Log(ext)
If(ext = ".pdf") Then
Dim i As Intent
File.Copy(File.DirRootExternal & "/Download/", filename, Starter.Provider.SharedFolder, filename)
i.Initialize(i.ACTION_VIEW, "")
Starter.Provider.SetFileUriAsIntentData(i,filename)
'Type must be set after calling SetFileUriAsIntentData
i.SetType("application/pdf")
StartActivity(i)
Else If(ext = ".pst") Then
StartActivity(act_stampapos)
End If
End If
End If
End If
End Sub
The error is in the permissions to access the download folder .. How can I solve?
thank you.