android – 仅用于文件的意图过滤器

在我们的应用程序中,我们要显示在“通过分享菜单中.所以我们将这个意图过滤器添加到我们的活动中:
<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:mimeType="application/*" />
    <data android:mimeType="audio/*" />
    <data android:mimeType="image/*" />
    <data android:mimeType="text/*" />
    <data android:mimeType="video/*" />
</intent-filter>

它的工作原理,我们的应用程序出现在共享菜单中.

然而,意图过滤器并不完全符合我们想要实现的目标:

>我们想出现在所有文件菜单中,无论mime类型是什么
>我们只想显示文件.到目前为止,如果用户想要分享一个简单的文本,因为它的mime类型将是文本/简单的,我们的应用程序出现在菜单中,我们不想要它.

所有文件文件的正确意图过滤器是什么?

提前致谢.

我们尝试添加scheme = file和host =“”或“*”,它不起作用,许多应用程序使用scheme = content来共享基于文件内容.

解决方法

we want to appear in the menu for all files,whatever there mime type is

尝试一个MIME类型的* / *.

we want to appear only for files. And up to Now,if the user wants to share a simple text,as its mime type will be text/plain,our app appears in the menu and we don’t want it. We tried to add scheme=file and host=”” or “*” and it doesn’t work as many app use a scheme=content to share file based content.

然后有两个< data>元素,一个用于内容方案,一个用于文件方案.

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

但是,请记住,内容方案并不意味着它必然是一个文件.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...