Radius Networks' Android iBeacon Library does exactly that. All you have to do to run it in the background is bind the IBeaconManager
to something with a long lifecycle. This can be a custom android.app.Application
object, or a Service of your own. Since you have already written your own service for your app, you could easily bind the IBeaconManager
to that service, and it would remain active in the background as long as the service runs. You could also use your service to send out broadcast intents if you wish, but for most use cases this is probably not necessary.
As for battery usage, the library's reference application has an example of how to set the background mode on the library so scans happen less often, saving battery. The pertinent code in that reference app is here:
@Override
protected void onPause() {
super.onPause();
if (iBeaconManager.isBound(this)) iBeaconManager.setBackgroundMode(this, true);
}
@Override
protected void onResume() {
super.onResume();
if (iBeaconManager.isBound(this)) iBeaconManager.setBackgroundMode(this, false);
}
Setting the background mode to true reduces the Bluetooth scans to happen only once very 5 minutes -- something similar to what iOS does. Based on tests on a Nexus 4, this reduces the phone's overall battery consumption from 95mA to 55mA (both of which numbers include the overall operating system drain.)
Full Disclosure: I work for Radius Networks and am the primary author of the Android iBeaconLibrary.