Android Question FileProvider and Opening PDF Application List

tsteward

Well-Known Member
Licensed User
My App downloads a PDF then using FileProvider it uses share to open the PDF. But the list applications offered does not include any pdf viewers which are installed on the device.

How can I show the PDF apps to select.

I have added to my Manifest
B4X:
AddApplicationText(
  <provider
  android:name="android.support.v4.content.FileProvider"
  android:authorities="$PACKAGE$.provider"
  android:exported="false"
  android:grantUriPermissions="true">
  <meta-data
  android:name="android.support.FILE_PROVIDER_PATHS"
  android:resource="@xml/provider_paths"/>
  </provider>
)
CreateResource(xml, provider_paths,
   <files-path name="name" path="shared" />
)
Then my app is as follows
B4X:
If job1.Success Then
                       
                    Dim out As OutputStream = File.OpenOutput(Starter.Provider.SharedFolder, fname, False)
                    File.Copy2(job1.GetInputStream, out)
                    out.Close
                    ProgressDialogHide
                    If foMenu.IsInitialized Then
                        If foMenu.MenuIsVisible Then
                            foMenu.HideFan
                        End If
                    End If
                    Log("file://" & Starter.Provider.SharedFolder & "/" & fname)
                    Dim in As Intent
                    in.Initialize(in.ACTION_SEND, "")
                    in.SetType("application/pdf")
                    in.PutExtra("android.intent.extra.STREAM", Starter.Provider.GetFileUri(fname))
                    in.Flags = 1 'FLAG_GRANT_READ_URI_PERMISSION
                    StartActivity(in)
                End If
When executed I get the list below to choose from :( no pdf applications in list.
 

Attachments

Almora

Active Member
Licensed User
this can help.

B4X:
        Dim FileName As String = "xx.pdf"
        File.Copy(File.DirAssets, FileName, Starter.Provider.SharedFolder, FileName)
        Dim in As Intent
        in.Initialize(in.ACTION_VIEW, "")
        Starter.Provider.SetFileUriAsIntentData(in, FileName)
        'Type must be set after calling SetFileUriAsIntentData
        in.SetComponent("android/com.android.internal.app.ResolverActivity")
        in.SetType("application/pdf")
        StartActivity(in)
 

tsteward

Well-Known Member
Licensed User
this can help.

B4X:
        Dim FileName As String = "xx.pdf"
        File.Copy(File.DirAssets, FileName, Starter.Provider.SharedFolder, FileName)
        Dim in As Intent
        in.Initialize(in.ACTION_VIEW, "")
        Starter.Provider.SetFileUriAsIntentData(in, FileName)
        'Type must be set after calling SetFileUriAsIntentData
        in.SetComponent("android/com.android.internal.app.ResolverActivity")
        in.SetType("application/pdf")
        StartActivity(in)
Thats perfect thank you!!!
 
Top