Domanda

I have an file which contains only text like "abcdefg", it can be downloaded from the web or opened from the local storage card. My idea was to give this file an exclusive extension, like .myfile and register ".myfile" with my app. I found some solutions in google, but nothing of them helped me. It seems like the file extension is indifferent, only the content type counts. however, I think I have to register an intent-filter in my android manifest with a mimeType and pathPattern...[...]. But what exactly I have to do?

    <intent-filter>

    <action android:name="android.intent.action.VIEW" />
    <action android:name="android.intent.action.EDIT" />
   <category android:name="android.intent.category.DEFAULT" />
<data
android:mimeType="application/myfile"
android:host="*" 
android:pathPattern=".*\\.myfile"/>
   </intent-filter>

this doesn't work for me :(

È stato utile?

Soluzione

  <action android:name="android.intent.action.VIEW" />
   <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />
 <data           android:host="*"
                android:mimeType="*/*"
                android:pathPattern=".*\\.myfile"
                android:scheme="file" />

This works!

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top