Android Intent-Filter custom filetype

前端 未结 1 1968
刺人心
刺人心 2020-12-11 09:58

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 Ex

相关标签:
1条回答
  • 2020-12-11 10:49

    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();
    

    ...

    0 讨论(0)
提交回复
热议问题