我正在创建一个必须出现在“共享”菜单上的应用程序,但我只希望它在共享的文件具有“foo”扩展名 (filename.foo) 时出现。 我必须补充一点,我不知道文件是什么 mime 类型,而且我是 android 的新手。
这是 list 中的代码:
<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>
元素无效,<data android:mimeType="*/*" />
除外.
I got a waring on the "pathPattern" line, saying this
在添加此 <intent-filter>
之前,您有同样的警告.您将在全新的 Android Studio 项目中收到相同的警告。与你的<intent-filter>
无关只是来自 IDE 的恼人噪音。
关于针对特定文件扩展名的 Android SEND 操作 Intent 过滤器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57599848/