在 onCreate
方法的主要 Activity 中,我注册了 broadcastReciver
但是当我关闭应用程序时,我总是得到这个错误:
@429d47e0 that was originally registered here. Are you missing a call to unregisterReceiver()?
04-10 23:40:48.161: E/ActivityThread(20989): at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:793)
04-10 23:40:48.161: E/ActivityThread(20989): at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:593)
04-10 23:40:48.161: E/ActivityThread(20989): at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1274)
04-10 23:40:48.161: E/ActivityThread(20989): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1261)
04-10 23:40:48.161: E/ActivityThread(20989): at android.app.ContextImpl.registerReceiver(ContextImpl.java:1255)
04-10 23:40:48.161: E/ActivityThread(20989): at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:372)
当我关闭应用程序时,我不想注销接收器。我能做些什么?我以编程方式注册接收器。
最佳答案
when I close application I don't want to unregister receiver
那么你不应该通过 registerReceiver()
注册它.通过 <receiver>
在 list 中注册它元素代替。然后,无论您的应用程序是否正在运行,它都可用。
关于android - 关闭android应用销毁广播接收器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15937049/