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) Not allowed in SDK29 and SDK30
os = File.OpenOutput(Starter.Provider.SharedFolder,filename,False) 'Alowed'
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,Starter.Provider.SharedFolder & "/" & filename) 'Or maybe 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