Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Intent-Filter custom filetype

First of all, I have scoured the SO and internet about this, an no solutions work. I've been trying to use the filebrowsers AndExplorer and Root Explorer to select *.las files and trigger my application.

This is my current intent filters (although it has gone through tons of revisions trying many different ideas):

<activity android:name=".Viewer"
            android:label="@string/app_name">
            <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:host="*" />
                <data android:pathPattern=".*\\.las" />
            </intent-filter>
</activity>

Does anyone have any idea how to trigger the custom filetype response? I want to be able to launch my application and grab the filepath of the file from both a file browser, and after an internet download of the file.

Thank so much!

like image 286
RedLeader Avatar asked Apr 13 '26 15:04

RedLeader


1 Answers

It looks like the big issue with file type intent filters is that allot of different programs handle the intents differently. I couldn't get AndExplorer to respond to any thing I found(i.e get it to open the .eva file). However I did get file manager and astro file browser working using the intent filters below. As an alternative having the app launch an activity to select the file dose work for all the file browsers I tried(if your using file manager it dose not return data like the other ones, so some adjustments have to be made(just saw this in debugging didnt write code to fix it), but instead I am just working on creating a custom file chooser, as it avoids any issues that other file managers users may have): ...

<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="content" android:host="*"
                android:pathPattern=".*\\.eva" />
            <data android:scheme="file" android:host="*"
                android:pathPattern=".*\\.eva" />
        </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:mimeType="*/*" />
             <data android:scheme="content" android:host="*"
                android:pathPattern=".*\\.eva" />
            <data android:scheme="file" android:host="*"
                android:pathPattern=".*\\.eva" />
        </intent-filter>

...

    Intent intent2Browse = new Intent();
    Toast.makeText(this, R.string.Choose_EVAKey_File, Toast.LENGTH_LONG).show();
    intent2Browse.addCategory(Intent.CATEGORY_OPENABLE);
    intent2Browse.setType("application/xml");
    intent2Browse.setAction(Intent.ACTION_GET_CONTENT);
    startActivityForResult(intent2Browse,Select_EVA_FILE);

....

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    if(requestCode == Select_EVA_FILE && resultCode == RESULT_OK) {
        Uri currFileURI = data.getData();
        path2Key = currFileURI.getPath();

...

like image 199
Bostwick Avatar answered Apr 16 '26 07:04

Bostwick