Integrate Android SDK

Adding Indoor Location to mobile application

Indoor Location is available within the Ubudu Android SDK. Before using it within the application the UbuduSDK instance must be created for the application:

UbuduSDK mUbuduSdk = UbuduSDK.getSharedInstance(getApplicationContext());

Indoor Location uses the delegate pattern to communicate with the application. Delegate object must implement com.ubudu.indoorlocation.UbuduIndoorLocationDelegate interface which defines all the events that must be handled by the application:

public class MyIndoorLocationDelegate implements UbuduIndoorLocationDelegate{ ... }

The UbuduIndoorLocationManager interface is available after UbuduSDK initialization:

MyIndoorLocationDelegate myIndoorLocationDelegate = new MyIndoorLocationDelegate(getApplicationContext());
UbuduIndoorLocationManager mIndoorLocationManager = mUbuduSdk.getIndoorLocationManager();

To bind the created delegate object with the SDK its reference has to be passed to the indoor location manager:


To use indoor location a map must be provided. It can be created on the Ubudu manager platform web site. To create and configure a map:

  • go on the Ubudu manager platform web site,

  • select a venue in "Venues & indoor maps" section,

  • add a new venue or go to the details of one of available venues,

  • click on the Maps button and click Add,

  • configure and save all the map's information.

Once the map creation process is completed the uuid (key) of the map can be used in the mobile application. To download the map in the application its uuid must be given as an argument to the following method of UbuduIndoorLocationManager, for example:


After calling the method above the map's data will be automatically downloaded from the Ubudu manager platform upon start of the indoor location. The following method is simply called to start indoor location:


There are two callback methods in the delegate's interface that handle start result:

void startSucceed();
void startFailed();

startFailed()* is called when the Indoor Location could not be started because of the network connection timeout. *startSucceed() is called when Indoor Location was started successfully. This means that location updates will be automatically passed to the delegate's methods.

To stop indoor location the following line of code must be executed:


stop() method stops the bluetooth monitoring related with indoor location purposes so it is important to invoke it when the location is no longer needed.

Using georeferenced map

As described in Indoor Location Android tutorial all indoor location events are passed to the application using a delegate pattern. The location engine calculates the position in the image coordinate system and sends UbuduPositionUpdate object containing estimated position info to the app by calling the delegate method:

positionChanged(UbuduPositionUpdate ubuduPositionUpdate)

UbuduPositionUpdate does not contain position's geographical coordinates but only pixel coordinates on the image. To convert the image pixel coordinates to geographical coordinates the geoCoordinates method of UbuduIndoorLocationManager must be used.

Here is an example of the delegate's positionChanged implementation:

public void positionChanged(UbuduPositionUpdate ubuduPositionUpdate) {
    if(mMap!=null) {
        UbuduPoint newPosition = ubuduPositionUpdate.getClosestNavigablePoint()
        UbuduCoordinates2D geoCoordinates = mSDK.getIndoorLocationManager().geoCoordinates(newPosition);
        mMap.setLocationOnMap(geoCoordinates.latitude(), geoCoordinates.longitude());

Note: The geographical coordinates returned by geoCoordinates method are given in degrees.

Displaying the map

The map image used on Ubudu manager platform during the map creation process is available in the Android SDK so it is possible to easily use it in the application. What is provided is the URL String to the map image file. This URL can be obtained from the UbuduMap object and the image file can be downloaded into the application. The following code shows how to download the file from the given URL String and create a Bitmap of the map:

String mapImageUrlString =;
try {
    URL url = new URL(mapImageUrlString);
    HttpURLConnection connection = (HttpURLConnection) url.openConnection();
    InputStream input = connection.getInputStream();
    Bitmap bitmap = BitmapFactory.decodeStream(input);
} catch (IOException e) {
    Log.e(TAG, "Could not download map image");