Background monitoring stops working when I press home

Hi guys, just got your Estimote beacons yesterday so new to the club.

I cant get the monitoring to work in the background. When the app is open it works perfectly. It triggers the onEntered event and the onExited event as it should. When I press the home button it no longer works. Logcat still gives me the startLEscan and stopLEscan but it can no longer trigger the onEntered event. After a little while it still triggers the onExited event though.

Any idea what’s going wrong? Im using a nexus 5 with android 6.0 atm.

Thanks in advance, here’s my application code.

public class MyApplication extends Application {

private BeaconManager beaconManager;

public void onCreate() {
    beaconManager = new BeaconManager(getApplicationContext());
    beaconManager.setMonitoringListener(new BeaconManager.MonitoringListener() {
        public void onEnteredRegion(Region region, List<Beacon> list) {
                    "Your gate closes in 47 minutes.",
                    "Current security wait time is 15 minutes, "
                            + "and it's a 5 minute walk from security to the gate. "
                            + "Looks like you've got plenty of time!");
        public void onExitedRegion(Region region) {
                    "Leaving gate","Goodbye"
    beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
        public void onServiceReady() {
            beaconManager.startMonitoring(new Region("monitored region",
                UUID.fromString("B9407F30-F5F8-466E-AFF9-25556B57FE6D"), null, null));

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);

I see that you are using example from our tutorial. Let me double check on Android 6 tomorrow this example.

Yep. Decided to test it out with your examples first before I start using it in my own app. Thanks for the speedy reply, let me know what you come up with!

Also my target SDK version is set to 22 instead of 23 because im having issues with the “dangerous” permissions atm.

Just FYI, you can try to generate yourself an example app from a template:

All the Android templates in there are already updated to account for having to request location permissions in SDK 23.

(Background monitoring, the “Notification” template will be most suitable.)

Ooooh thanks.
In the notification template both the background monitoring is working (still after pressing the home button) and the permission thing is working. I’ll go dig through this template and see if I can replicate it within my own app.


1 Like

Using the template as an example I got everything working. Im not sure where I went wrong in the first place but oh well.

Thanks!! :smiley:

1 Like