Android Question Empty PDF in PDF Intent

AkuryuBR

Member
Hi, I have a problem with the following code, when I use it the phone asks me to choose which application to open the pdf file with, I select it and I get this

B4X:
Sub apri_pdf(fn As String, cartella As String)
    File.Copy(File.DirInternal & "/" & cartella, fn, Starter.Provider.SharedFolder, fn)
    Dim file_pdf As Intent
    file_pdf.Initialize(file_pdf.ACTION_VIEW,Starter.Provider.GetFileUri(fn))
    file_pdf.SetType("application/pdf")
    file_pdf.WrapAsIntentChooser("Choose PDF Viewer") ' questa riga ti fa chiedere con che programmi vuoi aprirlo
    StartActivity(file_pdf)
End Sub

WhatsApp Image 2021-03-01 at 12.29.27.jpeg
 

AkuryuBR

Member
Worth testing with a different pdf viewer.
Thanks for the prompt reply, I tried with all the viewers I had in the phone, also if I use the same code but to send an email or share via whatsapp the file is correctly sent and I can open it through all the pdf viewers
B4X:
Sub invia_pdf(fn As String, cartella As String)
    File.Copy(File.DirInternal & "/" & cartella, fn, Starter.Provider.SharedFolder, fn)
    Dim email As Email
    email.To.Add("aaa@bbb.com")
    email.Subject = "subject"
    email.Attachments.Add(Starter.Provider.GetFileUri(fn))
    'email.Attachments.Add(Starter.Provider.GetFileUri(FileName)) 'second attachment
    Dim in As Intent = email.GetIntent
    in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
    StartActivity(in)
End Sub
 
Upvote 0
Top