user3332069
user3332069

Reputation: 43

iBeacon Android Service possible?

I was wondering if somebody could explain to me if it's possible to a service with the raduis networks android SDK? So I want to make it so it's running in the background when a user presses a button to start the service and then once the user detects the data packet it add's uuid, major, minor and proxid into a database. I would like to know how to do the service bit as I assume it's part of the SDK.

Sam

Upvotes: 0

Views: 326

Answers (1)

davidgyoung
davidgyoung

Reputation: 64916

Yes, it is possible to do this, and you do not even need an additional service. The Android iBeacon Library already runs as a service, and it can continue executing in the background simply by binding it to your own extended version of android.app.Application, which would be responsible for starting ranging for iBeacons. For your use case, you would insert the identifiers of each iBeacon into the database in the didRangeBeaconsInRegion method.

If you only want the service to start when the user presses a button, simply call a method in your android.app.Application class to start ranging from your android.app.Activity class that hosts the button.

You can see the basic setup from the code examples here.

You can do all of this with the open source library, but the Pro version provides additional tools that make it easier to run the service in the background and limit battery usage.

Upvotes: 1

Related Questions