0

广播接收器可以监听方案吗?活动示例。

<intent-filter >
   <data android:scheme="http"/>
   <action android:name="android.intent.action.VIEW" />
   <category android:name="android.intent.category.DEFAULT" />
   <category android:name="android.intent.category.BROWSABLE" />
</intent-filter>

编辑:公司正在使用它自己的协议..所以它不是 http 方案。

4

2 回答 2

0

是的,您可以在您的(而不是)中使用相同<intent-filter>的元素。<receiver><activity>

于 2012-12-19T23:03:34.250 回答
0

为了将来参考,这里是一个简单的工作示例:

发送广播如下:

Intent intent = new Intent("my.custom.action");
intent.setData(Uri.parse("myapp://apphost/"));
context.sendBroadcast(intent);

在您的清单中,使用以下意图过滤器注册广播接收器。

<intent-filter>
    <action android:name="my.custom.action"/>
    <data android:scheme="myapp" android:host="apphost"/>
</intent-filter>
于 2016-11-15T18:21:14.203 回答