Renjith
Renjith

Reputation: 3617

Forcefully add your app into application chooser

I shall give you an outline first before I dive into the problem. There are some files (images and pdf) on the email (say Gmail). When the user taps on any file of certain mime type, say image/jpeg, I want to add my app into the application chooser.

So here is my manifest.

<activity
        android:name="MyActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
        android:label="@string/app_name"
        android:launchMode="singleTop"
        android:alwaysRetainTaskState="true"
        android:windowSoftInputMode="stateHidden">

        <intent-filter>
            <action android:name="android.intent.action.PICK"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:mimeType="image/jpeg"/>
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.GET_CONTENT" />
            <category android:name="android.intent.category.DEFAULT"/>
            <category android:name="android.intent.category.OPENABLE"/>
            <data android:mimeType="image/jpeg"/>
        </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:host="*" android:mimeType="application/pdf" android:scheme="" android:pathPattern=".*/.pdf" /> 
            <data android:mimeType="application/pdf"/>
        </intent-filter>
 </activity>

I tried intent filters. Tried three different ways. Nothing worked. The app is not showing up in the application chooser. Am I lacking anything? Please share your thoughts!

Upvotes: 2

Views: 498

Answers (1)

Igor Tyulkanov
Igor Tyulkanov

Reputation: 5548

Try this:

<activity
    android:name="MyActivity"
    android:configChanges="keyboard|keyboardHidden|orientation|screenSize"
    android:label="@string/app_name"
    android:launchMode="singleTop"
    android:alwaysRetainTaskState="true"
    android:windowSoftInputMode="stateHidden">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="file" />
            <data android:host="*" />
            <data android:pathPattern=".*\\.pdf" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="file" />
            <data android:host="*" />
            <data android:mimeType="image/jpeg" />
        </intent-filter>
</activity>

Upvotes: 1

Related Questions