BroadcatReceiver的manifest.xml中宣称没有收到LocalBroadcastManager意图意图、manifest、BroadcatReceiver、LocalBroadca

由网友(六月离歌﹌泪倾城)分享简介:虽然可以通过code,因此接收通过LocalBroadcastManager.Ex公布的意图来声明一个'本地'的BroadcastReceiver LocalBroadcastManager.getInstance(本).registerReceiver(新FooReceiver(),新的IntentFilter(...

虽然可以通过code,因此接收通过LocalBroadcastManager.Ex公布的意图来声明一个'本地'的BroadcastReceiver

  LocalBroadcastManager.getInstance(本).registerReceiver(新FooReceiver(),新的IntentFilter(foo_intent_filter)); 

我不知道是否有可能通过的清单的.xml(清洁剂)。

宣布这样的接收器

当我使用'清单的方式',接收器的不是'接收'的意图。

 <接收        机器人:名字=FooReceiver        机器人:启用=真        机器人:出口=假>        &所述;意图滤光器>            <作用机器人:名字=foo_intent_filter/>        &所述; /意图滤光器>  < /接收器> 
AndroidManifest.xml 清单文件

我缺少的东西吗?或code-方式是唯一可行的解​​决方案。

感谢

解决方案   

我不知道是否有可能通过的manifest.xml(清洁剂)。

宣布这样的接收器

首先,这是不可能的。

二,在清单登记有一点做与它是干净。这是为了让Android的实例在其自己的接收器,让你可以在你的进程没有运行响应广播。而且,在你举具体的例子,它是允许系统上的任何应用程序向您发送广播。这些都不是相关的 LocalBroadcastManager

While it is possible to declare a 'Local' BroadcastReceiver via code so it receives intents published via a LocalBroadcastManager.Ex

LocalBroadcastManager.getInstance(this).registerReceiver(new FooReceiver(), new IntentFilter("foo_intent_filter"));

I wonder if it is possible to declare such receiver via the manifest.xml (cleaner) .

When I use the 'manifest way', the receiver is not 'receiving' the intents.

  <receiver
        android:name="FooReceiver"
        android:enabled="true"
        android:exported="false" >
        <intent-filter>
            <action android:name="foo_intent_filter" />
        </intent-filter>
  </receiver>

Am I missing something? or the code-way is the only viable solution.

Thanks

解决方案

I wonder if it is possible to declare such receiver via the manifest.xml (cleaner) .

First, that is not possible.

Second, registering in the manifest has little to do with it being "cleaner". It is to allow Android to instantiate the receiver on its own, so that you can respond to broadcasts when your process is not running. And, in the specific example that you cite, it is to allow any app on the system to send you a broadcast. Neither of those are relevant for LocalBroadcastManager.

阅读全文

相关推荐

最新文章