安卓的BroadcastReceiver不工作后安装 [英] Android BroadcastReceiver not working after install

查看:150
本文介绍了安卓的BroadcastReceiver不工作后安装的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好!我的工作,有一个BroadcastReceiver监听android.intent.action.PHONE_STATE,当手机状态改变(我用它检测到来电时运行code)在运行的应用程序。这工作正常,我的大多数测试手机,但似乎一些不触发接收器都没有。然而,一旦这些问题,手机会重新启动一切正常。

还有一个原因是这些手机需要BroadcaseReceiver之前重新启动可以挑不出什么了?有没有一种方法可以让我发现,如果它没有运行,并且手动启动的BroadcaseReceiver?我很为难,所以我AP preciate任何帮助,您可以提供。

感谢你。

解决方案
  

还有一个原因是这些手机需要重新启动之前,BroadcaseReceiver可以挑不出什么了?

假设你的应用有其的BroadcastReceiver 在清单中注册的 PHONE_STATE 播出时,应立即在工作安装。如果不是这样,那感觉就像一个越野车的ROM给我。

  

有没有一种方法可以让我发现,如果它没有运行,并且手动启动的BroadcaseReceiver?

没有,主要是因为它没有运行,通常情况下,即使一切运转正常。的一个实例的的BroadcastReceiver 在点创建意图 - < intent-滤光器> 的匹配,它被称为与的onReceive()的BroadcastReceiver 配置一旦的onReceive()的回报。

Greetings! I'm working on an application that has a BroadcastReceiver listening on "android.intent.action.PHONE_STATE", which is run when the phone state is changed (I used it to run code when an incoming call is detected). This works fine on most of my test phones, but a few don't seem to trigger the receiver at all. However, once these problem phones are restarted everything works as expected.

Is there a reason these phones need to be restarted before the BroadcaseReceiver can pick anything up? Is there a way I can detect if it isn't running and manually "start" the BroadcaseReceiver? I'm stumped, so I'd appreciate any help you can offer.

Thank You.

解决方案

Is there a reason these phones need to be restarted before the BroadcaseReceiver can pick anything up?

Assuming that your application has its BroadcastReceiver registered in the manifest for the PHONE_STATE broadcast, it should work immediately upon install. If it does not, it feels like a buggy ROM to me.

Is there a way I can detect if it isn't running and manually "start" the BroadcaseReceiver?

No, mostly because it's not running, usually, even when things are working. An instance of your BroadcastReceiver is created at the point of the Intent - <intent-filter> match, it is called with onReceive(), and the BroadcastReceiver is disposed of once onReceive() returns.

这篇关于安卓的BroadcastReceiver不工作后安装的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆