I had 2 BroadcastReceivers for watching SMS status. Code:
//纽约总部-when the SMS has been sent纽约总部-
registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context arg0, Intent arg1) {
...................
...................
}, new IntentFilter(SENT));
//纽约总部-when the SMS has been delivered纽约总部-
registerReceiver(new BroadcastReceiver(){
@Override
public void onReceive(Context arg0, Intent arg1) {
...................
...................
}, new IntentFilter(DELIVERED));
这两家接收器位于一个称为“信箱”的程序中。 一切工作都很出色,但以下情况令我失望。 当用户改变屏幕取向和投向一种例外情况时,申请被压制。 LogCat告诉我,该方案不想第二次登记广播接收人。 我认为,不存在问题,并增加了一个诱杀旗帜,以便今后在OnCreate(OnCreate)跳出电动。 但是,即使电离层监测系统(SMS)的号召第二次出现,第一次改变屏幕的定位,是LogCat的一个新征兆:
活动泄漏
一旦出现这种情况,就不可能跟踪SMS的状况,接收器不会工作。 但是,如果用户试图发挥并继续改变方向,则不管怎样,错误都不出现。
纽约总部
Who knows, what happened? The workaround like a block permission to change orientation not interesting. I need to understand what happened here and solve a current problem.
LOGcat
> 10-15 20:08:20.863: ERROR/ActivityThread(452): Activity
> com.example.android.Dima.MySoft has leaked IntentReceiver
> com.example.android.Dima.MySoft$3@40531880 that was originally
> registered here. 难道你没有向未出庭者发出呼吁吗? 10-15
> 20:08:20.863: ERROR/ActivityThread(452):
> android.app.IntentReceiverLeaked: Activity
> com.example.android.Dima.MySoft has leaked IntentReceiver
> com.example.android.Dima.MySoft$3@40531880 that was originally
> registered here. 难道你没有向未出庭者发出呼吁吗? 10-15
> 20:08:20.863: ERROR/ActivityThread(452): at
> android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:799)
> 10-15 20:08:20.863: ERROR/ActivityThread(452): at
> android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:575) 10-15
> 20:08:20.863: ERROR/ActivityThread(452): at
> android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:852)
> 10-15 20:08:20.863: ERROR/ActivityThread(452): at
> android.app.ContextImpl.registerReceiver(ContextImpl.java:839) 10-15
> 20:08:20.863: ERROR/ActivityThread(452): at
> android.app.ContextImpl.registerReceiver(ContextImpl.java:833) 10-15
> 20:08:20.863: ERROR/ActivityThread(452): at
> android.content.ContextWrapper.registerReceiver(ContextWrapper.java:318)
> 10-15 20:08:20.863: ERROR/ActivityThread(452): at
> com.example.android.Dima.MySoft.initSMS(MySoft.java:473) 10-15
> 20:08:20.863: ERROR/ActivityThread(452): at
> com.example.android.Dima.MySoft.onCreate(MySoft.java:263) 10-15
> 20:08:20.863: ERROR/ActivityThread(452): at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
> 10-15 20:08:20.863: ERROR/ActivityThread(452): at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785)
> 10-15 20:08:20.863: ERROR/ActivityThread(452): at
> android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1842)
> 10-15 20:08:20.863: ERROR/ActivityThread(452): at
> android.app.ActivityThread.access$1500(ActivityThread.java:132) 10-15
> 20:08:20.863: ERROR/ActivityThread(452): at
> android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038)
> 10-15 20:08:20.863: ERROR/ActivityThread(452): at
> android.os.Handler.dispatchMessage(Handler.java:99) 10-15
> 20:08:20.863: ERROR/ActivityThread(452): at
> android.os.Looper.loop(Looper.java:143) 10-15 20:08:20.863:
> ERROR/ActivityThread(452): at
> android.app.ActivityThread.main(ActivityThread.java:4268) 10-15
> 20:08:20.863: ERROR/ActivityThread(452): at
> java.lang.reflect.Method.invokeNative(Native Method) 10-15
> 20:08:20.863: ERROR/ActivityThread(452): at
> java.lang.reflect.Method.invoke(Method.java:507) 10-15 20:08:20.863:
> ERROR/ActivityThread(452): at
> com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
> 10-15 20:08:20.863: ERROR/ActivityThread(452): at
> com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597) 10-15
> 20:08:20.863: ERROR/ActivityThread(452): at
> dalvik.system.NativeStart.main(Native Method) 10-15 20:08:20.873:
> ERROR/ActivityThread(452): Activity com.example.android.Dima.MySoft
> has leaked IntentReceiver com.example.android.Dima.MySoft$4@40531f08
> that was originally registered here. Are you missing a call to
> unregisterReceiver()? 10-15 20:08:20.873: ERROR/ActivityThread(452):
> android.app.IntentReceiverLeaked: Activity
> com.example.android.Dima.MySoft has leaked IntentReceiver
> com.example.android.Dima.MySoft$4@40531f08 that was originally
> registered here. 难道你没有向未出庭者发出呼吁吗? 10-15
> 20:08:20.873: ERROR/ActivityThread(452): at
> android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:799)
> 10-15 20:08:20.873: ERROR/ActivityThread(452): at
> android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:575) 10-15
> 20:08:20.873: ERROR/ActivityThread(452): at
> android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:852)
> 10-15 20:08:20.873: ERROR/ActivityThread(452): at
> android.app.ContextImpl.registerReceiver(ContextImpl.java:839) 10-15
> 20:08:20.873: ERROR/ActivityThread(452): at
> android.app.ContextImpl.registerReceiver(ContextImpl.java:833) 10-15
> 20:08:20.873: ERROR/ActivityThread(452): at
> android.content.ContextWrapper.registerReceiver(ContextWrapper.java:318)
> 10-15 20:08:20.873: ERROR/ActivityThread(452): at
> com.example.android.Dima.MySoft.initSMS(MySoft.java:511) 10-15
> 20:08:20.873: ERROR/ActivityThread(452): at
> com.example.android.Dima.MySoft.onCreate(MySoft.java:263) 10-15
> 20:08:20.873: ERROR/ActivityThread(452): at
> android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1093)
> 10-15 20:08:20.873: ERROR/ActivityThread(452): at
> android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1785)
> ....
此外,还混淆了来自LOGCat的下一个短语。
难道你没有向未出庭者发出呼吁吗?
......为什么发生这种情况?