Monitor point of interest with beacon fencing

Find in this guide how-to monitor beacon proximity in a Android application through the Woosmap Geofencing SDK.

  1. Monitor beacon proximity thanks to the Indoor Search API
  2. Additional Permissions for Beacon Monitoring

Monitor beacon proximity thanks to the Indoor Search API

After starting the beaconTracking profile, beacon identifiers will be automatically retrieved from the Woosmap Platform and beacons will be automatically monitored by the SDK.

But first you need to set keys and a listener to monitor entry/exit events:

java
        @Override
protected void onCreate(Bundle savedInstanceState) {
    // Instanciate woosmap object
    this.woosmap = Woosmap.getInstance().initializeWoosmap(this);

    // Set private Woosmap key API - It is mandatory for requesting Woosmap Indoor Search API and monitor Woosmap Indoor POI
    WoosmapSettings.privateKeyWoosmapAPI = woosmapKey;

    // Instanciate the WoosRegionLogReadyListener to monitor beacon-fence events
    this.woosmap.setRegionLogReadyListener( new WoosRegionLogReadyListener() );

    // Beacon tracking - low power battery usage - no permanent notification in background - Beacon monitoring
    this.woosmap.startTracking( Woosmap.ConfigurationProfile.beaconTracking );
}

    

RegionLog callback is triggered each time a user enters or exits a beacon-fence:

java
        public class WoosRegionLogReadyListener implements Woosmap.RegionLogReadyListener {
    public void RegionLogReadyCallback(RegionLog regionLog) {

        // retrieve Indoor POI data from the device database
        IndoorBeacon beacon = WoosmapDb.getInstance(getApplicationContext()).getIndoorBeaconDAO().getBeaconByIdentifier(regionLog.idStore);
        Log.d("WoosmapSDKEvents", "Woosmap Geofencing Events:" + regionLog.eventName + " - Beacon UUID:" + beacon.beaconID);
}

    

You can use eventName data to distinguish between enter event (eventName = "woos_geofence_entered_event") and exit event (eventName = "woos_geofence_exited_event").

Additional Permissions for Beacon Monitoring

To monitor beacon proximity, please ensure that these four permissions are correctly declared in the Manifest file:

xml
        <uses-permission android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_SCAN"/>
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"/>

    
Was this article helpful?
Have more questions? Submit a request