0

When I press back button in Main Activity the iBeaconService is unbinding automatically. I didn't unbind the service in onDestroy too,

  1. Then how does this automatic unbinding happen?

    Due to this, I am not able to detect beacons when app runs in background mode.

  2. How do i monitor the beacons in background mode?

Also observed in logcat the message

"has leaked ServiceConnection com.radiusnetworks.ibeacon.IBeaconManager$1@42a28f18 that was originally bound here".

Thanks in advance.

Best Regards

  • I believe hitting the back button closes the application as supposed to hitting the home which puts the application into background mode. I could be wrong though but I had the same issue when I was messing around with iBeacon on android. – SuNnY_sYeD Jan 08 '14 at 21:25

1 Answers1

0

Android is killing the service connection when it disposes of your Activity. Hitting back causes that disposal to happen.

In order to range or monitor in the background, you must bind the iBeaconManager to something with a longer lifecycle -- like a custom Application class.

The Pro version of the Android iBeacon Library has helper classes that make this much easier. Take a look at the background launching sample code here:

http://developer.radiusnetworks.com/ibeacon/android/samples.html

davidgyoung
  • 63,876
  • 14
  • 121
  • 204