onExitedRegion - beginner issues

Hi I have made a simple app as per the getting started guide, however the onExitedRegion does not seem to trigger the notification. Any guidance would be appreciated.

I turned on the flip beacon off via the mobile app - so i could test…

package com.example.milesboyle.myapplication;

import android.content.Context;
import android.content.Intent;
import android.os.AsyncTask;

import com.estimote.coresdk.observation.region.beacon.BeaconRegion;
import com.estimote.coresdk.recognition.packets.Beacon;
import com.estimote.coresdk.service.BeaconManager;
import com.mashape.unirest.http.HttpResponse;
import com.mashape.unirest.http.Unirest;
import com.mashape.unirest.http.exceptions.UnirestException;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;
import java.util.UUID;

 * Created by milesboyle on 22/08/2017.

public class MyApplication extends Application {

    private BeaconManager beaconManager;

    // This is an AsyncTask - allows some 'work' to be done on a background
    // thread i.e. off the UI thread. Android makes you do things this way or it
    // will throw an exception
    private class RESTApi extends AsyncTask {

        protected Object doInBackground(Object[] params) {
            JSONObject payload = new JSONObject();
            try {
                // Here is the payload of the HTTP request to TRIRIGA
                payload.put("spi:cstCheckInColourCO", "#00ff00");
            } catch (JSONException e) {
            HttpResponse<String> response = null;
            try {
                response = Unirest.put("https://xx")
                        // HTTP BASIC AUTH INFO
                        .basicAuth("xx", "xx")
                        // Additional HTTP headers
                        .header("Accept", "application/xhtml+xml")
                        .header("Content-Type", "application/xml")
                        .header("x-method-override", "PATCH")
                        .header("PATCHTYPE", "MERGE")
                        // Put the JSON payload as a String in the HTTP request
                        // Get the value back as a String
            } catch (UnirestException e) {
            // Print out the HTTP response code to the Console
            // Print out the HTTP response headers to the Console
            return response.getBody();

        protected void onPostExecute(String result) {

    public void onCreate() {

        beaconManager = new BeaconManager(getApplicationContext());
        // add this below:
        beaconManager.setMonitoringListener(new BeaconManager.BeaconMonitoringListener() {
            public void onEnteredRegion(BeaconRegion region, List<Beacon> beacons) {
                System.out.println("ENTER REGION");
                        "NHS Welcome to your room",
                        "Your bed is S18"
                                + " Floor 2, Room 6A "
                                + "  ");

                new RESTApi().execute();
            public void onExitedRegion(BeaconRegion region) {
                // could add an "exit" notification too if you want (-:
                System.out.println("EXIT REGION");

        beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
            public void onServiceReady() {
                beaconManager.startMonitoring(new BeaconRegion(
                        3913, 39775));

    public void showNotification(String title, String message) {
        Intent notifyIntent = new Intent(this, MainActivity.class);
        PendingIntent pendingIntent = PendingIntent.getActivities(this, 0,
                new Intent[] { notifyIntent }, PendingIntent.FLAG_UPDATE_CURRENT);
        Notification notification = new Notification.Builder(this)
        notification.defaults |= Notification.DEFAULT_SOUND;
        NotificationManager notificationManager =
                (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
        notificationManager.notify(1, notification);

//    private String getBasicAuth() {
//        byte[] encodedBytes;
//        encodedBytes = "username" + ":" + "password".getBytes();
//    }



did you wait enough to see the notification? It comes within the 20 seconds after you really exited the region (the expiration time can be changed).