Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi guy's
user can open and read PDF file in my app (get file path from file manager) ...
but i need a way to open PDF file in my app when user click on file in file manager ! how to do it !?

What I have tried:

i try this : (in manifest)

XML
<pre><activity android:name=".FileLauncherActivity">    <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <category android:name="android.intent.category.OPENABLE" />
        <data android:pathPattern=".*\\.pdf" />
        <data android:pathPattern=".*\\..*\\.pdf" />
        <data android:pathPattern=".*\\..*\\..*\\.pdf" />
        <data android:pathPattern=".*\\..*\\..*\\..*\\.pdf" />
        <data
            android:host="*"
            android:mimeType="*/*"
            android:scheme="file" />
    </intent-filter>
</activity>

and in launcher activity : (to get file path an open pdf)
Java
filePath = Objects.requireNonNull(getIntent().getData()).getEncodedPath();

but after click on PDF (in device file manager) file nothing happens
Posted
Comments
David Crow 22-Aug-18 11:34am    
So you are wanting your app to be one of the ones listed in the "Open With" box when a PDF file is clicked? If so, have you tried something like:
<intent-filter>
  <action android:name="android.intent.action.VIEW" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:mimeType="application/pdf" />
</intent-filter>

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900