Skip to content

Getting core SDK objects instances

MGasztold edited this page Feb 1, 2017 · 4 revisions

The com.ubudu.sdk.UbuduSDK class has a shared instance that is the root of the API. It provides methods to obtain the managers, each of which deals with a different kind of areas: geofences and bluetooth LE beacons areas. If the kind of areas is not available on the device, then null is returned instead of a manager.

The manager classes share a common superclass, com.ubudu.sdk.UbuduAreaManager, and each deal with covariant subclasses. You can find details in the JavaDoc.

To start using UbuduSDK in your code first get an instance of it. We use singleton as there is no need of many instances of this class. :

UbuduSDK sdk=UbuduSDK.getSharedInstance(context);

Set the application namespace :

sdk.setNamespace(namespace);

Set delegate that handle actions from SDK :

UbuduBeaconManager mBeaconManager=sdk.getBeaconManager();
mBeaconManager.setAreaDelegate(someAreaDelegate);

UbuduGeofenceManager mGeofenceManager=sdk.getGeofenceManager();
mGeofenceManager.setAreaDelegate(someAreaDelegate);

Next start service by calling:

mBeaconManager.start();
mGeofenceManager.start();

From this moment application will start receiving geofences and beacons events and notify user in case of proper conditions according to the rules defined in Ubudu manager platform. To stop the SDK use following code:

mBeaconManager.stop();
mGeofenceManager.stop();

Starting these commands will first remove tracking any geofences and scanning for beacons and then will also stop the service taking care of all interactions.