I'm trying to use "android-beacon-library for detecting beacons" in Android. But I keep getting "Cannot contact service to set scan periods" in the log and beacons are not getting scanned. Any suggestions?
This log message indicates that the app is getting a RemoteException
talking to the BeaconService
, probably indicating that the BeaconService
was not started properly. The library will attempt to contact the service to adjust the scan periods as your app enters the foreground (an Activity is visible) or the background (no Activity is visible.) You probably get this log message once for each time your app enters the foreground or background when the BeaconService
is not started.
Why is your app's BeaconService
not started? There are lots of things that could cause this, but the most likely thing is an issue with the project setup.
If you are setting up your app for background detection, make sure you have a custom Application
class set up as described in the "Starting an App in the Background" section here: http://altbeacon.github.io/android-beacon-library/samples.html.
If you are explicitly binding to the service with the BeaconManager
class, verify you actually get a callback to onBeaconServiceConnect()
per the "Monitoring Example Code" here: http://altbeacon.github.io/android-beacon-library/samples.html.
If you are using Eclipse, perhaps manifest merging is not enabled. Edit your project.properties
file and make sure it has the line: manifestmerger.enabled=true
Full instructions on configuring Eclipse are here: http://altbeacon.github.io/android-beacon-library/configure.html
If none of these things solve your issue, then you really need to post your code that sets up beacon detection with the library so we can assist further.