BeaconService: has leaked ServiceConnection

Hi,
I am using beacon monitoring in my application. Initially it was running fine in eclipse, but now when I
migrated it to Android Studio it is now giving following error on “beaconManager.connect” method call.
has leaked ServiceConnection com.estimote.sdk.BeaconManager$InternalServiceConnection@48523f80 that was originally bound here.
One more thing that I’ve observed is it gives GC_FOR_FREED warning right before the exception is thrown.
Please put your solution here if anyone has fixed this before me.

Hi @Krushnat_Khawale,

The usual suspect for that is not calling disconnect on BeaconManager in your Activity’s onStop method.

Hi @wiktor

Thanks for the update, but I don’t want to stop looking for beacons, I want to look for the beacons even in the background. Something like scanning forever, Is that possible?

Thanks man.

I assume you currently have your BeaconManager in an Activity? If you want it work in the background, and keep scanning, you’ll need to move it to an Application subclass.

Check out our Android tutorial to learn how to go about it:
http://developer.estimote.com/android/tutorial/part-2-background-monitoring/

We also have a Notification template in Estimote Cloud, which demonstrates that:
https://cloud.estimote.com/#/apps/add/notification