相关疑难解决方法(0)

Android:将应用与自定义文件类型相关联

我有一个文件类型,扩展名是'.rfts'(实际上它只是存储一个代表音频放大器用户配置的JSON字符串).我希望能够在电子邮件附件(例如Gmail)中打开此文件,以便我可以从其他平板电脑导入用户设置.

这是我的清单看起来的样子(请注意,我没有在其中包含其他活动,但还有其他4个没有意图过滤器).

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/RFtheme" >
    <activity
        android:name=".activity.MainActivity"
        android:screenOrientation="landscape"
        android:windowSoftInputMode="adjustPan" >
        <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"/>
            <category android:name="android.intent.category.OPENABLE"/>
            <data android:scheme="file"/>
            <data android:mimeType="*/*"/>

            <data android:pathPattern="\\.rfts$"/>
            <data android:host="*"/>
        </intent-filter>
    </activity>

    <provider
        android:name=".model.FileProvider"
        android:authorities="com.rockfordcorp.app3sixty.provider"
        android:enabled="true"
        android:exported="true" >
    </provider>
</application>
Run Code Online (Sandbox Code Playgroud)

我一直在尝试其他问题的其他一些建议修复,但它们用于从浏览器打开pdf等内容.

当我尝试在Gmail中打开.rfts附件时,它会告诉我"您没有可以打开此文件的应用程序(.rfts).尝试搜索谷歌播放可以"

我不知道我需要在这里做些什么.我不知道Gmail会用什么来打开.rfts,也不知道它会使用什么方案.我尝试了几种不同的组合,但没有真正奏效.我还没有把Android正在寻找的类别,mimetype,模式和方案的神奇组合放到我的应用程序中.

编辑 成功,但尚未完成.

建议作为修复的问题是不合适的,原因是因为所需的方案实际上是"内容",而不是"文件"

有效的意图过滤器是

<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" android:mimeType="*/*" android:pathPattern=".*\\.rfts"/>
            <data android:scheme="content" android:pathPattern=".*\\.rfts" android:mimeType="application/octet-stream" />
            <!-- <data android:host="*"/> -->
        </intent-filter>
Run Code Online (Sandbox Code Playgroud)

没有 …

android file-association

6
推荐指数
1
解决办法
2698
查看次数

声明要通过蓝牙发送的“自定义文件”的MIME类型

我确实需要帮助来解决此问题:

我正在开发一个应用程序,以使用蓝牙将文件从应用程序传输到其他手机。当我想传输图像文件时,代码的一部分如下:

     intent.setType("image/*");
     i.putExtra(i.EXTRA_STREAM, uri);
     //here uri has the URI of the image that I want to send.
Run Code Online (Sandbox Code Playgroud)

android清单文件如下:

 <intent-filter>

       <action android:name="android.intent.action.MAIN"

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

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


 </intent-filter>
Run Code Online (Sandbox Code Playgroud)

和代码工作正常。现在我的问题是:同样,我想发送一个由以下行创建的文件:

   f = File.createTempFile("card", ".XCard", getExternalCacheDir());
Run Code Online (Sandbox Code Playgroud)

该文件的名称应如下所示:

   card12434247.Xcard
Run Code Online (Sandbox Code Playgroud)

现在,我在上面发布的代码中需要进行哪些修改?我应该如何在intent-filter中编写mimeType?

应该是什么行:

  intent.setType(...)?
Run Code Online (Sandbox Code Playgroud)

我应该如何修改它以便蓝牙能够处理此文件

  xyz.Xcard ??
Run Code Online (Sandbox Code Playgroud)

我应该如何声明通过蓝牙发送文件时需要的自定义mime类型?需要吗?请帮忙!!

android intentfilter android-manifest mime-types

5
推荐指数
1
解决办法
2596
查看次数

Android - 注册系统范围的扩展以进行 mime 类型映射

鉴于大多数电子邮件/文件管理器/社交应用程序附件将解析为具有“应用程序/八位字节流”mime 类型的内容 uri 方案,为自定义扩展解决方案注册意图过滤器都不再起作用。剩下的就是让应用程序为所有内容注册一个意图过滤器,这非常烦人:

        <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:host="*"
                android:mimeType="application/*"
                android:pathPattern=".*//.xxx" <!-- this wont work since uri may resolve to smth like this "dat=content://0@media/external/file/692 typ="   ->
                android:scheme="content" />
        </intent-filter>
Run Code Online (Sandbox Code Playgroud)

我设置了用于查询扩展的 mimetype 的 API:https ://developer.android.com/reference/android/webkit/MimeTypeMap

是否有 API 或其他方式为我的扩展添加新映射,即“.ext -> application/ext”,我们会在系统级别识别该映射?

file-extension android intentfilter mime-types

5
推荐指数
0
解决办法
363
查看次数

Android意图过滤器用于自定义文件扩展名

我正在尝试制作一个 Android 应用程序来打开扩展名为 .abc 的文件,这是 Android 清单 xml 中的我的应用程序部分

<application android:label="@string/app_name" android:icon="@drawable/icon">
    <activity android:name="com.example.app.ActName" android:label="AppName">
        <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="image/jpeg"/>
        </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:mimeType="*/*" />
            <data android:pathPattern=".*\\.abc" />
            <data android:host="*" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.MAIN"/>
            <category android:name="android.intent.category.LAUNCHER"/>
        </intent-filter>
    </activity>
</application>
Run Code Online (Sandbox Code Playgroud)

我使用了最热门和相关问题的所有经验

针对特定文件扩展名的 Android 意图过滤器?

Android意图过滤器:将应用程序与文件扩展名关联起来

Android 如何为自定义文件扩展名创建意图过滤器,但不使其成为手机上所有内容选择器的一部分

最后这不起作用 - 当我在 ES 文件浏览器中单击名为“name.abc”的文件时,它会询问我是否想以文本或图像等方式打开该文件,而实际上它应该只是打开该文件在我的应用程序中

我究竟做错了什么?只需在任何文件管理器中单击具有相应扩展名的文件即可启动应用程序的正确意图过滤器是什么?

更新。

看起来不同的 android 系统和不同的文件浏览器以不同的方式运行 - 一个意图过滤器在“ES 文件资源管理器”中的 4.2 和默认文件管理器中的 4.0.4 上工作得很好,但在 …

android android-intent

3
推荐指数
1
解决办法
8098
查看次数