0

I have made a app for viewing pdf documents in android.When I try to open any pdf from outside my app my app is displayed as an option to view that pdf inside Complet action using Dialog. I am using the mupdf library as a module in my app. How can I solve this problem?

This is what my AndroidManifest.xml file looks like:-

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.inevitable.org.shatayushi">

    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"></uses-permission>
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    <uses-permission android:name="android.permission.READ_PHONE_STATE"/>

    <application
        android:name=".GlobalClass"
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:supportsRtl="true"
        android:theme="@style/AppTheme">
        <activity android:name=".ShatayushiActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity android:name=".PayUActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN"/>

                <category android:name="android.intent.category.DEFAULT"/>
            </intent-filter>
        </activity>




        <activity
            android:name="com.artifex.mupdfdemo.MuPDFActivity"
            android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
            android:label="@string/app_name">
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:mimeType="application/vnd.ms-xpsdocument"/>
                <data android:mimeType="application/xps"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:mimeType="application/pdf"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:mimeType="application/x-cbz"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <data android:mimeType="application/epub+zip"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:scheme="file"/>
                <data android:mimeType="*/*"/>
                <data android:pathPattern=".*\\.xps"/>
                <data android:host="*"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:scheme="file"/>
                <data android:mimeType="*/*"/>
                <data android:pathPattern=".*\\.pdf"/>
                <data android:host="*"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:scheme="file"/>
                <data android:mimeType="*/*"/>
                <data android:pathPattern=".*\\.cbz"/>
                <data android:host="*"/>
            </intent-filter>
            <intent-filter>
                <action android:name="android.intent.action.VIEW"/>
                <category android:name="android.intent.category.DEFAULT"/>
                <category android:name="android.intent.category.BROWSABLE"/>
                <data android:scheme="file"/>
                <data android:mimeType="*/*"/>
                <data android:pathPattern=".*\\.epub"/>
                <data android:host="*"/>
            </intent-filter>
        </activity>
        <activity android:name="com.artifex.mupdfdemo.OutlineActivity"
            android:theme="@android:style/Theme.Holo.Light.DarkActionBar"
            android:label="@string/outline_title"
            >
        </activity>
        <activity
            android:name="com.artifex.mupdfdemo.PrintDialogActivity"
            android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
            android:label="@string/print">
        </activity>
    </application>

</manifest>

Any help or suggestion is appreciated.Thank you.

anup
  • 585
  • 12
  • 34
  • 1
    check http://stackoverflow.com/questions/8398514/hide-application-icon/11642671#11642671 and http://stackoverflow.com/questions/3760276/android-intent-filter-associate-app-with-file-extension – darwin Aug 10 '16 at 09:56

2 Answers2

1

That's means that there is an Intent Filter to get the action. See here https://developer.android.com/guide/components/intents-filters.html#Receiving

I don't know mupdf library but I guess there is in the manifest something like the following code (just an example):

<activity android:name="ShareActivity">
    <intent-filter>
        <action android:name="android.intent.action.SEND"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:mimeType="text/plain"/>
    </intent-filter>
</activity>
br00
  • 1,391
  • 11
  • 21
1

As I could not see the code snippet of the intent filter, my suggestion would be to refer How can I have my app appear in the intent chooser only for certain urls?

This link might also be helpful in your case I don't want my app to appear on the chooser dialog when opening URL's

Hope this helps.

Community
  • 1
  • 1
Neh
  • 442
  • 4
  • 7