Android应用内计费只允许一个BroadcastReceiver接收计费广播?
我已经让谷歌的示例应用内计费应用程序(地下城)工作得很好。但是,我正在尝试为我正在编写的应用程序注册第二个计费接收器,但我无法这样做。似乎只有我的 AndroidManifest.xml 中声明的第一个接收器才是接收广播的接收器,但第一个接收器之后的任何接收器都不会接收广播。在运行时,我已经使用 isOrderedBroadcast() 确认广播不是有序广播,因此我并没有在某处中止广播(只能中止有序广播)。任何对此的帮助将不胜感激。
I have gotten Google's sample in-app billing app (Dungeons) working just fine. However, I'm trying to register a second billing receiver for an app I'm writing, and I'm unable to do so. It seems as though only the first receiver declared in my AndroidManifest.xml is the one that receives broadcasts, but any following the first one do not receive broadcasts. At run-time, I've confirmed that the broadcast is not an ordered broadcast by using isOrderedBroadcast(), so it's not as though I'm aborting the broadcast somewhere (only ordered broadcasts can be aborted). Any help with this would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许第一个接收器需要先取消注册,然后第二个接收器才能执行其尝试执行的操作。在您的 Activity 中,重写 onStop() 方法,以便在 Activity 关闭时取消注册广播接收器。这对我来说很有效。
Perhaps the first receiver needs to be unregistered before the second one can do what it is trying to do. In your activity, override the onStop() method so that the broadcast receiver is unregistered when the activity closes. This is what has worked for me.