Unwanted notification

Hello,

I am developing an android application using Estimote SDK

I want my app to send a notification each time it ‘enters’ a beacon region, even if the app is killed. And doesn’t send another notification until the user exit the region and re-enter it.

This code works for me, but it sends a notification many times although the app is not exiting the region!

This code works for me, but it sends a notification many times although the app is not exiting the region!

Which code? (:

forgot to attach it:scream:

public class MyApplication extends Application {

private BeaconManager beaconManager;

@Override
public void onCreate() {
    super.onCreate();



    beaconManager = new BeaconManager(getApplicationContext());

    beaconManager.setMonitoringListener(new BeaconManager.MonitoringListener() {
        @Override
        public void onEnteredRegion(Region region, List<Beacon> list) {
            showNotification(
                    "Hello","I am your notification");
        }



        @Override
        public void onExitedRegion(Region region) {
            // could add an "exit" notification too if you want (-:
        }







    });



    beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
        @Override
        public void onServiceReady() {
            beaconManager.startMonitoring(new Region(
                    "monitored region",
                    UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D"),
                    null, null));
        }
    });

//beaconManager.setBackgroundScanPeriod(2000l);

}


public void showNotification(String title, String message) {
    Intent notifyIntent = new Intent(this, MainActivity.class);
    notifyIntent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    PendingIntent pendingIntent = PendingIntent.getActivities(this, 0,
            new Intent[] { notifyIntent }, PendingIntent.FLAG_UPDATE_CURRENT);
    Notification notification = new Notification.Builder(this)
            .setSmallIcon(android.R.drawable.ic_dialog_info)
            .setContentTitle(title)
            .setContentText(message)
            .setAutoCancel(true)
            .setContentIntent(pendingIntent)
            .build();
    notification.defaults |= Notification.DEFAULT_SOUND;
    NotificationManager notificationManager =
            (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.notify(1, notification);
}

}