0

I have an pdf reader app that is designed to give selection option to open any pdf file in the system within application. I have referred the below link: Why isn't my app on the list of apps to open txt file? I just want my app to be on the list of opening only pdf files, but now my app is on the list for every type of files. I did have , but I wonder if I should specify mimeType. What should I do to restrict my app to only appearing on list of opening pdf files?

Thanks in Advanced, AA.

Community
  • 1
  • 1
Aarushi
  • 251
  • 1
  • 3
  • 9
  • Hey Arushi .. Hope you got your solution here.. http://stackoverflow.com/questions/8055859/android-opening-pdf-isnt-working – Mit Bhatt Nov 13 '13 at 09:04
  • Above code is not restricts my application to open only pdf file. My code. Opening all types of file. I want to open only pdf file through my application.Thanks. – Aarushi Nov 13 '13 at 09:50
  • okie,, Sorry for that.. I'm doing R&D for tht. – Mit Bhatt Nov 13 '13 at 10:19

1 Answers1

3

I used to write a similar app. I posted my AndroidManifest.xml segment for your reference:

<activity
    android:name=".OpenFileActivity"
    android:configChanges="orientation|keyboardHidden"
    android:label="@string/app_name" >
    <intent-filter>
        <action android:name="android.intent.action.VIEW" >
        </action>

        <category android:name="android.intent.category.DEFAULT" >
        </category>
        <category android:name="android.intent.category.BROWSABLE" >
        </category>

        <data
            android:mimeType="application/pdf"
            android:scheme="file" >
        </data>
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" >
        </action>

        <category android:name="android.intent.category.DEFAULT" >
        </category>
        <category android:name="android.intent.category.BROWSABLE" >
        </category>

        <data
            android:mimeType="application/pdf"
            android:scheme="content" >
        </data>
    </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW" >
        </action>

        <category android:name="android.intent.category.DEFAULT" >
        </category>
        <category android:name="android.intent.category.BROWSABLE" >
        </category>

        <data
            android:host="*"
            android:pathPattern=".*\.[pP][dD][fF]"
            android:scheme="file" />
    </intent-filter>
</activity>
Daniel Liu
  • 489
  • 3
  • 5
  • Above code is not restricts my application to open only pdf file. My code. Opening all types of file. I want to open only pdf file through my application.Thanks. – Aarushi Nov 13 '13 at 09:42
  • You may specify mimeType to "application/pdf". – Daniel Liu Nov 13 '13 at 11:13
  • I tried to change the mimeType from "*/*" to "application/pdf" but still text files also can open through my application. – Aarushi Nov 13 '13 at 11:17
  • Do you have other intent filter in Manifest file? I tried it on my samsung S4. It works well. – Daniel Liu Nov 13 '13 at 11:39
  • In my manifest launcher screen has intent filter as and one intent filter from my activity i.e two filter in manifest. – Aarushi Nov 13 '13 at 11:48