Wednesday, 22 May 2019

Open custom filetype in Samsung file explorer

I have two custom filetypes that my app can handle that I would like to be able to open from a wide variety of other apps. What I have is working for many including Gmail and the Settings file explorer, but there several third file managers (including Samsung My Files and Astro File Manager) that do not recognize these filetypes as belonging to my app. Is there a way to craft an intent filter that will enable these file explorer apps to recognize that these files should be opened by my app?

Here's the existing intent filters:

<intent-filter>
    <action android:name="android.intent.action.MAIN" />

    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

<!-- See http://stackoverflow.com/questions/1733195/android-intent-filter-for-a-particular-file-extension/2062112#2062112 -->


<!--
        Capture content by MIME type, which is how Gmail broadcasts
        attachment open requests.  pathPattern and file extensions
        are ignored, so the MIME type *MUST* be explicit, otherwise
        we will match absolutely every file opened.
-->
<intent-filter
    android:icon="@drawable/book"
    android:label="@string/app_name"
    android:priority="50">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />

    <!-- needed for properly formatted email messages -->
    <data
        android:mimeType="application/vnd.bloom"
        android:scheme="content" />
    <!-- needed for mangled email messages -->
    <data
        android:mimeType="application/bloom"
        android:scheme="content" />
    <!-- needed for properly formatted email messages -->
    <data
        android:mimeType="application/vnd.bloomd"
        android:scheme="content" />
    <!-- needed for mangled email messages -->
    <data
        android:mimeType="application/bloomd"
        android:scheme="content" />
    <!-- needed for properly formatted email messages -->
    <data
        android:mimeType="application/vnd.bloombundle"
        android:scheme="content" />
    <!-- needed for mangled email messages -->
    <data
        android:mimeType="application/bloombundle"
        android:scheme="content" />
    <!-- needed for mangled email messages -->
    <data
        android:mimeType="application/octet-stream"
        android:scheme="content" />
</intent-filter>

<!--
        Capture file open requests (pathPattern is honoured) where no
        MIME type is provided in the Intent.  An Intent with a null
        MIME type will never be matched by a filter with a set MIME
        type, so we need a second intent-filter if we wish to also
        match files with this extension and a non-null MIME type
        (even if it is non-null but zero length).
-->
<intent-filter
    android:icon="@drawable/book"
    android:label="@string/app_name"
    android:priority="50">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />

    <data android:scheme="file" />
    <data android:host="*" />

    <!--
            Work around Android's ugly primitive PatternMatcher
            implementation that can't cope with finding a . early in
            the path unless it's explicitly matched.
    -->
    <data android:pathPattern=".*\\.bloomd" />
    <data android:pathPattern=".*\\..*\\.bloomd" />
    <data android:pathPattern=".*\\..*\\..*\\.bloomd" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\.bloomd" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.bloomd" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.bloomd" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.bloomd" />
    <data android:pathPattern=".*\\.bloombundle" />
    <data android:pathPattern=".*\\..*\\.bloombundle" />
    <data android:pathPattern=".*\\..*\\..*\\.bloombundle" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\.bloombundle" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.bloombundle" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.bloombundle" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.bloombundle" />
</intent-filter>

<!--
        Capture file open requests (pathPattern is honoured) where a
        (possibly blank) MIME type is provided in the Intent.  This
        filter may only be necessary for supporting ES File Explorer,
        which has the probably buggy behaviour of using an Intent
        with a MIME type that is set but zero-length.  It's
        impossible to match such a type except by using a global
        wildcard.
-->
<intent-filter
    android:icon="@drawable/book"
    android:label="@string/app_name"
    android:priority="50">
    <action android:name="android.intent.action.VIEW" />

    <category android:name="android.intent.category.BROWSABLE" />
    <category android:name="android.intent.category.DEFAULT" />

    <data android:scheme="file" />
    <data android:host="*" />
    <data android:mimeType="*/*" />

    <!--
            Work around Android's ugly primitive PatternMatcher
            implementation that can't cope with finding a . early in
            the path unless it's explicitly matched.
    -->
    <data android:pathPattern=".*\\.bloomd" />
    <data android:pathPattern=".*\\..*\\.bloomd" />
    <data android:pathPattern=".*\\..*\\..*\\.bloomd" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\.bloomd" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.bloomd" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.bloomd" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.bloomd" />
    <data android:pathPattern=".*\\.bloombundle" />
    <data android:pathPattern=".*\\..*\\.bloombundle" />
    <data android:pathPattern=".*\\..*\\..*\\.bloombundle" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\.bloombundle" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\.bloombundle" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\.bloombundle" />
    <data android:pathPattern=".*\\..*\\..*\\..*\\..*\\..*\\..*\\.bloombundle" />
</intent-filter>



from Open custom filetype in Samsung file explorer

No comments:

Post a Comment