Issue
I have this intent filter to open files with extension "custom" in my app:
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="content" />
<data android:host="*" />
<data android:mimeType="*/*" />
<data android:pathPattern=".*\\.custom" />
<data android:pathPattern=".*\\..*\\.custom" />
<data android:pathPattern=".*\\..*\\..*\\.custom" />
<data android:pathPattern=".*\\..*\\..*\\..*\\.custom" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.custom" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.custom" />
<data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.custom" />
</intent-filter>
But in this case it doesn't open:
Also it works well when opening file from Telegram chat.
How can I open my custom files from anywhere?
UPD
I've added pdf mime-type for tests. It opens pdf files from everywhere. Here are the intents I got:
- for download folder (works with custom extension):
Intent { act=android.intent.action.VIEW dat=content://com.google.android.apps.nbu.files.provider/1/file:///storage/emulated/0/Download/Untitled.pdf typ=application/pdf flg=0x13000001 cmp=team.sls.testapp/.ActivityMain }
- for Telegram (works with custom extension):
Intent { act=android.intent.action.VIEW dat=content://org.telegram.messenger.provider/media/Telegram/Telegram Documents/2_5276292126848585208.pdf typ=application/pdf flg=0x13000001 cmp=team.sls.testapp/.ActivityMain }
- for downloads folder in second image (doesn't work with custom extension):
Intent { act=android.intent.action.VIEW dat=content://com.google.android.apps.nbu.files.provider/2/1863 typ=application/pdf flg=0x13000001 cmp=team.sls.testapp/.ActivityMain }
- for opening from Dowdload manager from notification panel (doesn't work with custom extension):
Intent { act=android.intent.action.VIEW dat=content://com.android.providers.downloads.documents/document/1508 typ=application/pdf flg=0x13000003 cmp=team.sls.testapp/.ActivityMain }
Solution
How can I open my custom files from anywhere?
There is no way to open custom files from anywhere.
@CommonsWare helped me to figure out the reason in my another question.
The problem is that Uri
values in Intents
do not have file extensions.
What are the alternatives? We can use standard application/
{whatever} mime-type to open files in our application. But we have to select "Open with..." menu item in file explorer then.
Answered By - badadin
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.