2019-09-18 10:22:47.562 10511-10511/com.abc.www.xxx E/ActivityThread: Activity com.abc.www.xxx.activity.login.LoginActivity has leaked ServiceConnection com.abc.www.xxx.activity.login.LoginActivity$12@a57f5c that was originally bound here
android.app.ServiceConnectionLeaked: Activity com.abc.www.xxx.activity.login.LoginActivity has leaked ServiceConnection com.abc.www.xxx.activity.login.LoginActivity$12@a57f5c that was originally bound here
at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1538)
at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1430)
at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1622)
at android.app.ContextImpl.bindService(ContextImpl.java:1574)
at android.content.ContextWrapper.bindService(ContextWrapper.java:697)
at com.abc.www.xxx.activity.login.LoginActivity.bindService(LoginActivity.java:885)
at com.abc.www.xxx.activity.login.LoginActivity.onCreate(LoginActivity.java:185)
at android.app.Activity.performCreate(Activity.java:7183)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1220)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2910)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3032)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
如果在activity中绑定了服务,而没有在destory中,写unbind,会出现这种异常。在onDestroy方法中加入了对服务的解绑操作即 unbindService就成功解决了。
dialog中如果activity已经finish()掉但dialog还没dissmiss()时也会报类似的溢出错误