Service was originally bound here

原创 2015年11月20日 11:24:11

1.错误原因:

在Activity运行了bindService()开启Service(全名:

boolean android.content.ContextWrapper.bindService(Intent service,ServiceConnection conn, int flags));但在destory()里没有调用unbindService ()关闭Service(

void android.content.ContextWrapper.unbindService(ServiceConnection conn));

就会出现这种异常;
1.解决办法,在Activity中destory()里加上unbindService(ServiceConnection conn)即可;

1.贴出我的throw Exception,仅作参考:

11-20 16:22:03.012: E/ActivityThread(6004):

android.app.ServiceConnectionLeaked:Activitycom.android.bluetooth.DeviceScanActivity has leaked ServiceConnectioncom.android.bluetooth.DeviceScanActivity$1@428afb28 that was originally boundhere;

at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:972);

at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:866);

at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1637);

atandroid.app.ContextImpl.bindService(ContextImpl.java:1620);

at android.content.ContextWrapper.bindService(ContextWrapper.java:517);

atcom.android.bluetooth.DeviceScanActivity.addDevice (DeviceScanActivity.java:542);

at com.android.bluetooth.DeviceScanActivity$3$1.run(DeviceScanActivity.java:308);

atandroid.os.Handler.handleCallback(Handler.java:733);

atandroid.os.Handler.dispatchMessage(Handler.java:95);

at android.os.Looper.loop(Looper.java:136);

atandroid.app.ActivityThread.main(ActivityThread.java:5133);

atjava.lang.reflect.Method.invokeNative(Native Method);

atjava.lang.reflect.Method.invoke(Method.java:515);

at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:795);

atcom.android.internal.os.ZygoteInit.main(ZygoteInit.java:611);

at dalvik.system.NativeStart.main(NativeMethod);


版权声明:本文为博主原创文章,未经博主允许不得转载。

相关文章推荐

Android开发之服务连接泄露异常

写了个Android service,用来完成一些耗时的网络IO和远程设备连接。在Activity中,先用startService( )启动服务,然后调用bindService( )将Activity...

Activity has leaked ServiceConnection that was originally bound here

当我们采用bindService(service, conn, flags)而不是 startService(service)启动服务Service的时候,如果我们在关闭Activity的时候没有释放...

出现leaked ServiceConnection 的解决办法

出现leaked ServiceConnection 的解决办法Activity com.skyace.service.MainActivity has leaked ServiceConnectio...

service 没有unbind时was originally bound here错误

service 没有unbind时was originally bound here错误 service 没有unbind时was originally bound here错误    在程序中,...

解决has leaked ServiceConnection com.baidu.location.c@427b6780

解决“has leaked ServiceConnection com.baidu.location.c@427b6780 that was originally bound here”的错误,需要修...

Service com.android.exchange.ExchangeService has leaked ServiceConnection

来自:http://lvqionghua.blog.163.com/blog/static/1852774201341541226744/  android.app.ServiceConnection...

Android常见错误之android.widget.LinearLayout@4375f248 that was originally added here

Activity xiaosi.tab.tabActivity has leaked window android.widget.LinearLayout@4375f248 that was orig...
  • SJF0115
  • SJF0115
  • 2012年03月10日 14:11
  • 11774

解决has leaked ServiceConnection com.baidu.location.c@427b6780

解决“has leaked ServiceConnection com.baidu.location.c@427b6780 that was originally bound here”的错误,需要修...

Activity has leaked ServiceConnection that was originally bound here

当我们采用bindService(service, conn, flags)而不是 startService(service)启动服务Service的时候,如果我们在关闭Activity的时候没有释放...

解决has leaked ServiceConnection com.baidu.location.c@427b6780

解决“has leaked ServiceConnection com.baidu.location.c@427b6780 that was originally bound here”的错误,需要修...
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:Service was originally bound here
举报原因:
原因补充:

(最多只允许输入30个字)