android 活动中的广播接收器在一段时间后没有收到意图
我是 android 的初学者..我面临以下问题.... 问题:在从该主活动启动的服务中接收到 NETWORK_STATE_CHANGED_ACTION 后,android 活动中的广播接收器未接收意图。
更多详细信息: 我的应用程序中有一个活动和一个意图服务。我从活动的 onCreate() 方法调用该服务。 服务和活动之间的通信是通过活动中的广播接收器接收我从服务发送的意图(例如UIintent)...这个意图基本上是根据我的服务中可用的状态更新用户界面... 。
直到某个时间点,我的活动才能从服务接收意图(UIintent)广播。之后,活动中不会收到我的意图(UIintent)
我已在我的服务中注册了 NETWORK_STATE_CHANGED_ACTION。 当服务收到 NETWORK_STATE_CHANGED_ACTION 意图时,我的活动不再接收意图(UIintent)。
我的活动中的 UIintent 注册是在 oncreate() 本身内完成的。 我还尝试在 onPause() 中注销并在 onResume() 中再次注册,但仍然徒劳。有人可以帮助我解决这个问题吗? 所有广播接收器都是在代码中注册的,而不是在 xml 中注册的。
i am a beginner to android..i am facing the below issue....
Problem : broadcastreceiver within android activity is not receiving intents after receiving NETWORK_STATE_CHANGED_ACTION within a service started from that main activity..
More details:
i have an activity and an intentservice in my application.i invoke the service from the onCreate() method of the activity.
communication between the service and the activity is via a broadcastreceiver in the activity which receives the intent(say UIintent) i send from the service...this intent is basically to update the user interface based on the status available in my service....
my activity is able to receive the intent(UIintent) broadcast from the service until a certain point of time.after that my intent(UIintent) is not received in the activity.
I have registered for NETWORK_STATE_CHANGED_ACTION within my service.
The point after which my activity is not receiving the intent(UIintent) is when the service receives the NETWORK_STATE_CHANGED_ACTION intent.
Registering for the UIintent in my activity is done within the oncreate() itself.
I also tried unregistering in onPause() and registering it again in onResume() still in vain.Can someone help me in resolving this issue.
All the broadcast receivers are registered in code and not in xml.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您没有使用任何意图过滤器,请尝试使用意图过滤器,它们会屏蔽广播接收器,使其免受您不希望处理的意图的影响。意图过滤器必须应用于广播意图和广播接收器。
Try out intent filters if you are not using any, they shield the Broadcast Receiver from intent which you do not wish to process. Intent filters have to be applied on both the broadcast intent and the broadcast receiver.