Question

How can I start iBeacon while my app is not running. I mean there must me some broadcast receiver which can be placed in my app's Manifest.

Edit:

As this question is misleading, let me rephrase it again:

I've created a project which detects the iBeacon 1. In activity running state. 2. In service.

If I want be get notified whenever an iBeacon gets detected, when application is not running I've got one option that is through Service. But that will drain the battery. So is there any broadcast receiver which an notify my app as soon as any iBeacon is detected.

The Demo code which I've written for this is: https://github.com/Vinayrraj/Android-iBeacon-Demo

Was it helpful?

Solution

You simply have to run a service in the background to do this. Code has to run to detect iBeacons (e.g. Radius Networks' Android iBeacon Library). If you don't have a service running, then what is going to do the background detection?

Yes, anything running in the background will drain the battery, but it won't drain the battery much if it is sleeping most of the time. Reducing the scan frequency can save battery life. iOS7, for example, the OS only does a bluetooth scan once every few minutes when no foreground app is ranging for iBeacons.

So the solution to the battery problem is to reduce the frequency of the bluetooth scans in the service so they give you an acceptable trade-off between battery life and iBeacon detection speed. If you are using my company's Android iBeacon Library, then. you can adjust the constant for this to your liking.

EDIT: My company has released a "Pro" version of the Android iBeacon Library with a built-in ability to launch an app when one or more iBeacons are seen. It also includes an automatic battery saver to slow down bluetooth scans whenever your app is in the background. See code examples here: http://developer.radiusnetworks.com/ibeacon/android/pro/download.html

OTHER TIPS

In order to do something on Android, you have to create an Application. In order to make something work, something that you coded, you need to run your app. So it is not possible to do something like what you want. Sorry, mate.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top