0

Hi i am developing an app to open txt files.When user touches a txt file on sd card my app should shown in open with list. My app is working file with other android version but phone doesn't show my app in open with list. Phone is generel mobile gm5+ .i don't know it is because of the phone or android version. here is my manifest

 <activity
        android:name=".ui.SplashActivity"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </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="text/plain" />
            <data android:pathPattern=".*\\.txt" />


        </intent-filter>
    </activity>

Thanks for your help.

Fatih POLAT
  • 147
  • 1
  • 4
  • 16

2 Answers2

0

check if you have permission of

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

Try something like this

<activity 
    android:name=".ui.SplashActivity"
    android:screenOrientation="portrait">
    <intent-filter>
       <action android:name="android.intent.action.MAIN" />
       <category android:name="android.intent.category.LAUNCHER" />
   </intent-filter>
    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
        <category android:name="android.intent.category.DEFAULT"/>
        <data android:scheme="file" />       
        <data android:mimeType="*/*" />
        <data android:pathPattern=".*\\.txt" />
    </intent-filter>
</activity>

<data android:scheme="file" /> => this define that the file must be local, not from http or else

<data android:mimeType="*/*" /> => match any mime type (to be specific use mimeType="text/plain")

<data android:pathPattern=".*\\.txt" /> => this is where you specify what extension you want to match

intent-filter can contain multiple actions as per need also two intent-filter should also need to work

Hope this help

Sushant Gosavi
  • 3,647
  • 3
  • 35
  • 55
0

You must use content as well:

    <data android:scheme="content"
          android:mimeType="text/*" />

You can also use pathpattern here or specify other mimeTypes

emirua
  • 498
  • 5
  • 14