Android Question FileProvider and Opening PDF Application List

Discussion in 'Android Questions' started by tsteward, May 7, 2019.

  1. tsteward

    tsteward Active 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
    Code:
    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
    Code:
    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.
     

    Attached Files:

  2. Almora

    Almora Active Member Licensed User

    this can help.

    Code:
    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)
     
    Kope, Erel and tsteward like this.
  3. tsteward

    tsteward Active Member Licensed User

    Thats perfect thank you!!!
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice