Reputation: 45
I am making an app using Bluetooth LE Service. What I noticed is the device gets disconnected automatically after some time after app goes to background. Can someone explain reason for this?
I am getting following error.
02-12 16:48:27.497 11695-11695/main.nesttech.com.nesttechble E/ActivityThread﹕ Activity main.nesttech.com.nesttechble.MainActivity has leaked ServiceConnection main.nesttech.com.nesttechble.MainActivity$1@428fc528 that was originally bound here
android.app.ServiceConnectionLeaked: Activity main.nesttech.com.nesttechble.MainActivity has leaked ServiceConnection main.nesttech.com.nesttechble.MainActivity$1@428fc528 that was originally bound here
at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:979)
at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:873)
at android.app.ContextImpl.bindServiceAsUser(ContextImpl.java:1818)
at android.app.ContextImpl.bindService(ContextImpl.java:1806)
at android.content.ContextWrapper.bindService(ContextWrapper.java:503)
at main.nesttech.com.nesttechble.MainActivity.connectDevice(MainActivity.java:429)
at main.nesttech.com.nesttechble.MainActivity.access$200(MainActivity.java:93)
at main.nesttech.com.nesttechble.MainActivity$4$1.run(MainActivity.java:399)
at android.os.Handler.handleCallback(Handler.java:730)
at android.os.Handler.dispatchMessage(Handler.java:92)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:5414)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:525)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1187)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1003)
at dalvik.system.NativeStart.main(Native Method)
Upvotes: 0
Views: 311
Reputation: 1829
The log you posted are just losing the ServiceConnection
, which is used to connect your Activity
to your Service
object by bindService
.
Beware it's Android Service
object but not BLE service implemented in the peripheral.
This has nothing to do with BLE connection, probably your background Activity
just get killed by the system to free memory, and you did not do unbindService
in suitable lifecycle callback before the activity dies.
Upvotes: 1