How to register my Android application to open my own file extension, not for all files

I am trying to associate my application with my user extension.

like here

I succeeded, but now my application wants to open for each file , pdf ... or anyway. My user files do not have a specific minetype type, so I am trying to use different combinations of pathPattern , but have not found anything working on Android 4.

<data android:pathPattern=".*\\.custom" />

This works well on Android 2.3.3, but not bad on v4.

What should I do to make it work? Any tips? Thank!

+4
source share
1 answer

Well, finally, I managed to make it work better, I still do not quite understand how manifest intent filters should work, but here's what I did:

The intent intercept app showed me the mimetype of my files: "text / plain", so first I added:

 <data android:mimeType="text/plain" >

So, at the moment, my application is no longer displayed for all files.

Then, when I create the file, I added: sendIntent.setType("application/custom"); and I added the corresponding mimetype type to the manifest file.

This method worked well on both Android 2 and 4 phones that I tested.

If someone found or wrote something about how the intent filter works, please let me know!

+1
source

Source: https://habr.com/ru/post/1536981/


All Articles