5

我查看了意图过滤器文档,但无法弄清楚这个特定的意图过滤器。

我希望使用 ACTION_SEND,因为我只希望该应用程序显示在其他应用程序的“共享”菜单中。如果意图的文本是 url,我只想显示在共享菜单中。例如,从 Android 浏览器的共享菜单中共享的内容。如果它只是文本而不是 url,我不希望应用程序出现在共享菜单中。

到目前为止,我所拥有的是:

<intent-filter android:label="Label">
  <action android:name="android.intent.action.SEND" />
  <category android:name="android.intent.category.DEFAULT" />
  <data android:mimeType="text/*" />
</intent-filter>    

但是,这将接收任何文本,而不仅仅是 url。

谢谢

4

1 回答 1

1

You can create IntentFilter objects programmatically, and they can filter on URI schema among other things... much more control.

I thought subclassing IntentFilter would give you event more, but they made all the variations on "match" final so you can't override them in a subclass. Bah!

Eurika!

You can specify a data "scheme" instead of a mimetype. Just ask for "http" and "https" (in separate intent filters?).

<intent-filter>
  ...
  <data android:scheme="http"/>
</intent-filter>
于 2010-11-05T20:47:31.730 回答