Service was originally bound here

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,service)