Android 为特定文件扩展名发送操作意图过滤器?

Android SEND action intent filter for a particular file extension?

我正在创建一个必须显示在“共享”菜单上的应用程序,但我只希望它在共享的文件具有 'foo' 扩展名 (filename.foo) 时显示。 我必须补充一点,我不知道该文件是什么 mime 类型,而且我是 android.

的新手

这是清单中的代码:

<intent-filter>
    <action android:name="android.intent.action.SEND" />
    <category android:name="android.intent.category.DEFAULT" />
    <data android:scheme="file" />
    <data android:mimeType="*/*" />
    <data android:pathPattern=".*\.foo" />
    <data android:host="*" />
</intent-filter>

我在 "pathPattern" 行收到一条警告,说的是:

App is not indexable by Google Search; consider adding at least one Activity with an ACTION-VIEW intent filter.

所以我假设代码确实有效,但使用的是 VIEW 操作,而不是 SEND 操作。

I only want it to appear when the file that is being shared has a 'foo' extension (filename.foo)

文件未在 Android 中共享。内容是共享的。内容没有文件扩展名——它有一个 MIME 类型。 Android.

不支持你想要的

This is the code inside the manifest

ACTION_SEND 不使用 Uri。除了 <data android:mimeType="*/*" />.

之外,所有 <data> 元素均无效

I got a waring on the "pathPattern" line, saying this

您在添加此 <intent-filter> 之前收到了同样的警告。您将在全新的 Android Studio 项目中收到相同的警告。它与您的 <intent-filter> 无关,只是来自 IDE.

的恼人噪音