Greetings Community,
So here is my project in a nutshell. I'm opening an XML file that contains collaterals and the URL's where the PDF's are located at. I store the XML into a Listview. It loads the XML pefectly thanks to XmlSax. When the Listview click event is executed, i use the HttpUtils.Download to download the PDF file. It downloads the PDF file fine into the File.DirInternal location. I then do a validation check to see if the file does indeed exist in the location and thus execute the Intent to open the PDF. This is where it fails. It finds the file, and opens Adobe Acrobat, but it fails and states "The file path is not valid."
Can someone explain as to why this is happening? Here is the code snippet
List View Click Event:
JobDone (HttpUtils Callback):
OpenPDF (It errors out here. It finds that it does exists and executes fine, but errors when opening the PDF in Adobe Acrobat)
Thanks.
So here is my project in a nutshell. I'm opening an XML file that contains collaterals and the URL's where the PDF's are located at. I store the XML into a Listview. It loads the XML pefectly thanks to XmlSax. When the Listview click event is executed, i use the HttpUtils.Download to download the PDF file. It downloads the PDF file fine into the File.DirInternal location. I then do a validation check to see if the file does indeed exist in the location and thus execute the Intent to open the PDF. This is where it fails. It finds the file, and opens Adobe Acrobat, but it fails and states "The file path is not valid."
Can someone explain as to why this is happening? Here is the code snippet
List View Click Event:
B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)
PdfUrl = Value
HttpUtils.Download("Job2", PdfUrl)
End Sub
JobDone (HttpUtils Callback):
B4X:
Sub JobDone (Job As String)
Select Job
Case "Job1"
If HttpUtils.IsSuccess(XmlUrl) Then
'XmlFile = HttpUtils.GetInputStream(XmlUrl)
Dim out As OutputStream
If File.Exists(File.DirInternal, "ql2400.xml") Then
File.Delete(File.DirInternal, "ql2400.xml")
End If
out = File.OpenOutput(File.DirInternal, "ql2400.xml", True)
File.Copy2(HttpUtils.GetInputStream(XmlUrl), out)
out.Close
Dim in As InputStream
in = File.OpenInput(File.DirInternal, "ql2400.xml")
parser.Parse(in, "Parser")
in.Close
End If
Case "Job2"
If HttpUtils.IsSuccess(PdfUrl) Then
'XmlFile = HttpUtils.GetInputStream(XmlUrl)
Dim out As OutputStream
If File.Exists(File.DirInternal, "ql2400.pdf") Then
File.Delete(File.DirInternal, "ql2400.pdf")
End If
out = File.OpenOutput(File.DirInternal, "ql2400.pdf", True)
File.Copy2(HttpUtils.GetInputStream(PdfUrl), out)
out.Close
Dim in As InputStream
in = File.OpenInput(File.DirInternal, "ql2400.pdf")
OpenPDF
in.Close
End If
End Select
HttpUtils.Complete = False
End Sub
OpenPDF (It errors out here. It finds that it does exists and executes fine, but errors when opening the PDF in Adobe Acrobat)
B4X:
Sub OpenPDF()
Dim i As Intent 'Requires a reference to the Phone library
Dim uri As String
If File.Exists(File.DirInternal, "ql2400.pdf") Then
uri = "file://" & File.Combine(File.DirInternal, "ql2400.pdf")
'Msgbox(uri,"test")
i.Initialize(i.ACTION_VIEW, uri)
i.SetType("application/pdf")
i.WrapAsIntentChooser("Choose PDF Viewer")
StartActivity(i)
End If
End Sub
Thanks.