Android SDK issue?

Hi all,

I have an issue when receiving the pull messages on Android devices. Normally we cannot pull the msg from ibeacon to mobile, but after restart the mobile, I can get the message displaying on my mobile.
Can anyone please help to let me know what happens with my app? Does the issue come from SDK?

Can you share some more information? Android device, Android OS version, code snippet, debug logs[1], SDK version, etc.?

[1] EstimoteSDK.enableDebugLogging(true);

Hi Heypiotr,

I got the issue on android version 6.0 and 6.0.1. The devices are Samsung S6, honor, nexus 5/7.
Below is the code we were thinking it generated the errors:

BeaconManager beaconManager = new BeaconManager(getApplicationContext());
beaconManager.setMonitoringListener(monitoringListener);
beaconManager.setRangingListener(rangingListener);
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
    @Override
    public void onServiceReady() {
        // Start monitoring a region
        Region enterRegion = new Region(uuid + ":" + beacon_id, UUID.fromString(uuid), nearestBeacon.getMajor(), nearestBeacon.getMinor());
        beaconManager.startMonitoring(enterRegion);
    }
});

Looking forward to hearing from you soon.

The code looks just fine, any chance for the debug logs?

UPDATE: actually, on a second look, the snippet’s a bit incomplete, e.g., can’t see your ranging/monitoring listeners, and in the enterRegion you’re using nearestBeacon and uuid variables which I also can’t see where they’re coming from and what they are. Debug logs will still be helpful too (:

Appreciated your quick response!

I would like to share the log which generates from App debugs. I’m trying to get the log from SDK, will share to you too once I have it.

03-09 11:32:34.311 3755-3755/com.myapp.dc E/com-myapp-dc: at (BeaconService.java:202) [connectBeaconManager]connectBeaconManager
03-09 11:32:34.321 3755-3755/com.myapp.dc E/BeaconService: initBeacon
03-09 11:32:34.341 3755-3755/com.myapp.dc I/EstimoteSDK: com.estimote.sdk.service.BeaconService.onCreate:309 Creating service for android version 19
03-09 11:32:34.411 3755-3755/com.myapp.dc E/BeaconService: connect
03-09 11:32:36.001 3755-3755/com.myapp.dc E/Ranging Beacon: BeaconID: 13903:1848
03-09 11:32:36.001 3755-3755/com.myapp.dc E/Ranging Beacon: Beacon UUID: 750a8862-cdb8-cab4-c65b-f6166e36b31c
03-09 11:32:36.011 3755-3755/com.myapp.dc E/Ranging Beacon: Start Monitoring BeaconID: Region{identifier=750a8862-cdb8-cab4-c65b-f6166e36b31c:13903:1848, proximityUUID=750a8862-cdb8-cab4-c65b-f6166e36b31c, major=13903, minor=1848, secure=false}
03-09 11:32:36.091 3755-3755/com.myapp.dc E/Monitoring Beacon: onEnteredRegion region_id: 13903:1848
03-09 11:32:36.091 3755-3755/com.myapp.dc E/Monitoring Beacon: onEnteredRegion uuid: 750a8862-cdb8-cab4-c65b-f6166e36b31c
03-09 11:32:36.091 3755-3755/com.myapp.dc E/Monitoring Beacon: onEnteredRegion Identifier: 750a8862-cdb8-cab4-c65b-f6166e36b31c:13903:1848
03-09 11:32:36.131 3755-3755/com.myapp.dc E/com-myapp-dc: at (IBeaconFrequency.java:63) [canPushIBeaconMessage]data: {}
03-09 11:32:36.141 3755-3755/com.myapp.dc E/com-myapp-dc: at (IBeaconFrequency.java:41) [saveFrequencyState]data: {}
03-09 11:32:36.141 3755-3755/com.myapp.dc E/com-myapp-dc: at (IBeaconFrequency.java:110) [saveDataIBeaconFrequency]saveDataIBeaconFrequency 3: {"":1489033956152}
03-09 11:32:37.151 3755-3755/com.myapp.dc E/com-myapp-dc: at (BeaconService.java:461) [pushAndStoreMessage]currentDate: 09-03-2017 11:32:36
03-09 11:32:37.151 3755-3755/com.myapp.dc E/com-myapp-dc: at (BeaconService.java:462) [pushAndStoreMessage]startDate: 08-03-2017 18:31:00
03-09 11:32:37.151 3755-3755/com.myapp.dc E/com-myapp-dc: at (BeaconService.java:463) [pushAndStoreMessage]endDate: 10-03-2017 18:31:00
03-09 11:32:37.161 3755-3755/com.myapp.dc E/com-myapp-dc: at (BeaconService.java:465) [pushAndStoreMessage]pushAndStoreMessage: ENTER REGION - Test iBeacon message shown weekly_2002 13903:1848

Hi!

Could you provide us with the snippet of the MonitoringListener and RangingListener that you use?
And we can’t say from the code you posted if you’ve initialized the RangingListener.

Thanks!

Hi Raphael,
There is the piece of code. Appreciated any suggestions.

 //TODO
public BeaconManager.RangingListener rangingListener = new BeaconManager.RangingListener() {

    @Override
    public void onBeaconsDiscovered(Region region, List<Beacon> list) {
        if (!list.isEmpty()) {
            Beacon nearestBeacon = list.get(0);
            if (nearestBeacon == null) {
                return;
            }
            String beacon_id = nearestBeacon.getMajor() + ":" + nearestBeacon.getMinor();
            String uuid = String.valueOf(nearestBeacon.getProximityUUID());
            Log.e("Ranging Beacon", "BeaconID: " + beacon_id);
            Log.e("Ranging Beacon", "Beacon UUID: " + uuid);
           // Toast.makeText(getBaseContext(),beacon_id,Toast.LENGTH_SHORT).show();
            if ((beacon_id != null && !beacon_id.contains("null")) && (uuid != null && !uuid.equalsIgnoreCase("null"))) {
                if (hmIBeaconMessage.containsKey(beacon_id) && !arrEnterRegion.contains(uuid)) {
                    Region enterRegion = new Region(uuid + ":" + beacon_id, UUID.fromString(uuid), nearestBeacon.getMajor(), nearestBeacon.getMinor());
                    beaconManager.startMonitoring(enterRegion);
                    Log.e("Ranging Beacon", "Start Monitoring BeaconID: " + enterRegion.toString());
                }
            }
        }
    }
};

/*
* TODO
* Display_at = 1 (onEnteredRegion)
* Display_at = 2 (onExitedRegion)
* Display_at = 3 (onEnteredRegion & onExitedRegion)
*/
public BeaconManager.MonitoringListener monitoringListener = new BeaconManager.MonitoringListener() {
    @Override
    public void onEnteredRegion(Region region, List<Beacon> list) {
        try {
            String region_id = region.getMajor() + ":" + region.getMinor();
            Log.e("Monitoring Beacon", "onEnteredRegion region_id:\n" + region_id);
            Log.e("Monitoring Beacon", "onEnteredRegion uuid:\n" + region.getProximityUUID());
            Log.e("Monitoring Beacon", "onEnteredRegion Identifier:\n" + region.getIdentifier());
            if (region_id.contains("null")) {
                return;
            }
            // Save all beacon nearest to get coupon
            arrBeaconInRange.add(region_id);
            saveNearestBeacon(arrBeaconInRange);
            //
            arrEnterRegion.add(String.valueOf(region.getProximityUUID()));
            arrMonitoringRegion.add(region);
            //
            if (!list.isEmpty() && !region_id.contains("null")) {
                Beacon nearestBeacon = list.get(0);
                if (nearestBeacon == null) {
                    return;
                }
                if (hmIBeaconMessage.containsKey(region_id)) {
                    // Push Notification
                    pushBeaconDisplayAt(3, region_id, Const.BeaconPriority.SELF);
                    pushBeaconDisplayAt(1, region_id, Const.BeaconPriority.SELF);
                }
            }
        } catch (Exception e) {
            DebugLog.loge(e);
        }
    }

    @Override
    public void onExitedRegion(Region region) {
        try {
            String region_id = region.getMajor() + ":" + region.getMinor();
            Log.e("Monitoring Beacon", "onExitedRegion region_id:\n" + region_id);
            Log.e("Monitoring Beacon", "onEnteredRegion Identifier:\n" + region.getIdentifier());
            if (region_id.contains("null")) {
                return;
            }
            arrBeaconInRange.remove(region_id);
            saveNearestBeacon(arrBeaconInRange);
            if (region_id != null) {
                if (hmIBeaconMessage.containsKey(region_id)) {
                    // Push Notification
                    pushBeaconDisplayAt(3, region_id, Const.BeaconPriority.SELF);
                    pushBeaconDisplayAt(2, region_id, Const.BeaconPriority.SELF);
                }
            }
        } catch (Exception e) {
            DebugLog.loge(e);
        }
    }
};

Hi there,
Waiting for your ideas please…

Hi @heypiotr,
Could you please help response on my issue? There is blocker for us now. Thanks!

Sorry for the long wait!

The one potential source of problems I see is, in your monitoring listener:

if (!list.isEmpty() && !region_id.contains("null")) {
    Beacon nearestBeacon = list.get(0);
    if (nearestBeacon == null) {
        return;
    }
    if (hmIBeaconMessage.containsKey(region_id)) {
        // Push Notification
        pushBeaconDisplayAt(3, region_id, Const.BeaconPriority.SELF);
        pushBeaconDisplayAt(1, region_id, Const.BeaconPriority.SELF);
    }
}

From our onEnteredRegion documentation: “This list may not reflect all beacons around that are matching given region.”

Hence, I’d suggest simply … getting rid of most of these “ifs”, e.g., replace all of the code above with simply:

pushBeaconDisplayAt(3, region_id, Const.BeaconPriority.SELF);
pushBeaconDisplayAt(1, region_id, Const.BeaconPriority.SELF);

In general though, I think this code is much more complex than it could be, which can lead to all sorts of little problems. I assume the intention is simply to show some kind of notification when you enter range of some beacon? Is that right?