Intent. Filter program that appears in the "Open With"

0

Today the option to "open with" lists several programs that are installed on the phone and including my app. I would like my app to be an option only for files in the extension it works, in this case "* .rlc".

        <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>

        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT"/>
            <data android:mimeType="*/*"/>
            <data android:pathPattern=".*\.rlc" />
        </intent-filter>
    </activity
    
asked by anonymous 13.01.2017 / 13:30

2 answers

1

See how the syntax of <data> :

<data android:scheme="string"
      android:host="string"
      android:port="string"
      android:path="string"
      android:pathPattern="string"
      android:pathPrefix="string"
      android:mimeType="string" />

Now see below how I can be set on your activity on AndroidManifest.xml so that it works properly open on just a specific extension. For example .rlc :

<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=".*\.rlc" />
    <data android:host="*" />
</intent-filter>
    
13.01.2017 / 14:38
0

Add in the AndroidManufest.xml the "mimeType" in your Intent with the extension that will be supported.

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

More information can be found at Official Documentation

    
13.01.2017 / 13:44