Android-Proximity-SDK icon indicating copy to clipboard operation
Android-Proximity-SDK copied to clipboard

Proximity observations not stopping even after doing proximityHandler.stop()

Open Raj1015120 opened this issue 7 years ago • 5 comments

Prerequisites

  • [X ] Put an X between the brackets on this line if you have done all of the following:
    • My beacons have Estimote Monitoring enabled (Check it in the Estimote Cloud, or via app)
    • My Android device/devices supports BLE and has Android OS version >= 5.0.0
    • My Android device/devices have bluetooth enabled
    • My app has Location Permissions granted

Basic information

Estimote SDK version: [0.5.0]

Android devices affected: [Redmi Note 5]

Android OS version affected: [7.1.2]

Beacon hardware version: [F.3.3]

Description

[Proximity observations not stopping]

Expected behavior: [Proximity observations should stop when am calling "proximityHandler.stop()"]

Actual behavior: [Proximity observations not stopping when I call "proximityHandler.stop()"]

Additional information

My code:

private ProximityObserver.Handler proximityHandler = null;

private ProximityObserver proximityObserver; private ProximityZone checkoutZone, laneAzone, laneBzone;

onCreate (){ this.proximityObserver = new ProximityObserverBuilder(getApplicationContext(), cloudCredentials) .withOnErrorAction(new Function1<Throwable, Unit>() { @Override public Unit invoke(Throwable throwable) { Logger.logError(TAG, "Beacon observer error : "+throwable.getMessage()); return null; } }) .withEstimoteSecureMonitoringDisabled() .withTelemetryReportingDisabled() .withBalancedPowerMode() .build();

startCheckoutZone(); startLaneAzone(); startLaneBzone();

    requirementCheckandProceed();

}

void requirementCheckandProceed() {

    RequirementsWizardFactory.createEstimoteRequirementsWizard()
            .fulfillRequirements(this, new Function0<Unit>() {
                @Override
                public Unit invoke() {
                    Logger.logInfo(TAG,  " Beacon observation - Requirements full filled");
                    proximityHandler = proximityObserver.addProximityZones(checkoutZone, laneAzone, laneBzone).start();
                    return null;
                }
            }, new Function1<List<? extends Requirement>, Unit>() {
                @Override
                public Unit invoke(List<? extends Requirement> requirements) {
                    Logger.logInfo(TAG,   "Beacon observation - Missing requirements : " + requirements);
                    return null;
                }
            }, new Function1<Throwable, Unit>() {
                @Override
                public Unit invoke(Throwable throwable) {
                    Logger.logError(TAG,   "Beacon observation - Requirements error : " + throwable);
                    return null;
                }
            });
}

void startCheckoutZone() {

    checkoutZone = this.proximityObserver.zoneBuilder()
            .forAttachmentKeyAndValue("zone", "checkoutzone")
            .inCustomRange(beaconFarRange)
            .withOnEnterAction(new Function1<ProximityAttachment, Unit>() {
                @Override
                public Unit invoke(ProximityAttachment proximityAttachment) {
                    Logger.logInfo(TAG,"Enter Action -  Check out zone !!!");
                   
                    }
                    return null;
                }
            })
            .withOnChangeAction(new Function1<List<? extends ProximityAttachment>, Unit>() {
                @Override
                public Unit invoke(List<? extends ProximityAttachment> proximityAttachments) {
                    return null;
                }
            })
            .withOnExitAction(new Function1<ProximityAttachment, Unit>() {
                @Override
                public Unit invoke(ProximityAttachment proximityAttachment) {
                    Logger.logInfo(TAG, "Exit Action -  Check out zone!!!");
                   
                    }
                    return null;
                }
            })
            .create();

    this.proximityObserver.addProximityZone(checkoutZone);
}

void startLaneAzone() {

    laneAzone = this.proximityObserver.zoneBuilder()
            .forAttachmentKeyAndValue("lane", "A")
            .inCustomRange(beaconNearRange)
            .withOnEnterAction(new Function1<ProximityAttachment, Unit>() {
                @Override
                public Unit invoke(ProximityAttachment proximityAttachment) {
                    Logger.logInfo(TAG, "Enter Action - Lane A !!!");
                    
                    }
                    return null;
                }
            })
            .withOnExitAction(new Function1<ProximityAttachment, Unit>() {
                @Override
                public Unit invoke(ProximityAttachment proximityAttachment) {
                    return null;
                }
            })
            .withOnChangeAction(new Function1<List<? extends ProximityAttachment>, Unit>() {
                @Override
                public Unit invoke(List<? extends ProximityAttachment> proximityAttachments) {
                    return null;
                }
            }).create();
    this.proximityObserver.addProximityZone(laneAzone);

}

void startLaneBzone() {

    laneBzone = this.proximityObserver.zoneBuilder()
            .forAttachmentKeyAndValue("lane", "B")
            .inCustomRange(beaconNearRange)
            .withOnEnterAction(new Function1<ProximityAttachment, Unit>() {
                @Override
                public Unit invoke(ProximityAttachment proximityAttachment) {
                    Logger.logInfo(TAG, "Enter Action - Lane B !!!");
                   
                    }
                    return null;
                }
            })
            .withOnExitAction(new Function1<ProximityAttachment, Unit>() {
                @Override
                public Unit invoke(ProximityAttachment proximityAttachment) {
                    return null;
                }
            })
            .withOnChangeAction(new Function1<List<? extends ProximityAttachment>, Unit>() {
                @Override
                public Unit invoke(List<? extends ProximityAttachment> proximityAttachments) {
                    return null;
                }
            }).create();
    this.proximityObserver.addProximityZone(laneBzone);

}

//In one scenario i need to start again needTostartAgain() { this.proximityObserver.start(); }

stopObserver(){

proximityHandler.stop(); }

So totally 2 times i started the observer. But stopped one time after 2 times it started.

The issue is its not stopping. Can you please guide how to stop it properly ? Thanks in advance.

Logs:
07-13 14:59:40.778 27625-27625/com.test E/ProximityFlow: Beacon observer error : Monitoring stopped while being inside one of the zones. From now on it is impossible to tell when the user exits the zone. You should handle this case properly in your App logic.
        07-13 14:59:40.779 27625-27625/com.test E/ProximityFlow: Beacon observer error : Monitoring stopped while being inside one of the zones. From now on it is impossible to tell when the user exits the zone. You should handle this case properly in your App logic.
        07-13 14:59:40.781 27625-27625/com.test E/ProximityFlow: Beacon observer error : Monitoring stopped while being inside one of the zones. From now on it is impossible to tell when the user exits the zone. You should handle this case properly in your App logic.
        07-13 14:59:40.783 27625-27625/com.test E/ProximityFlow: Beacon observer error : Monitoring stopped while being inside one of the zones. From now on it is impossible to tell when the user exits the zone. You should handle this case properly in your App logic.
        07-13 14:59:40.784 27625-27625/com.test E/ProximityFlow: Beacon observer error : Monitoring stopped while being inside one of the zones. From now on it is impossible to tell when the user exits the zone. You should handle this case properly in your App logic.
        Beacon observer error : Monitoring stopped while being inside one of the zones. From now on it is impossible to tell when the user exits the zone. You should handle this case properly in your App logic.
        07-13 14:59:40.808 27625-27625/com.test E/HW-JPEG-DEC: [HME_JPEG_DEC_Delete](3321): HME_JPEG_DEC_Delete: decoder_ctx=null
        07-13 14:59:40.811 27625-27625/com.test I/HwPointEventFilter: do not support AFT because of no config
        07-13 14:59:41.800 27625-27625/com.test I/ProximityFlow: Enter Action - Lane B !!!
        07-13 14:59:41.805 27625-27625/com.test I/ProximityFlow: Enter Action - Lane B !!!
        07-13 14:59:41.808 27625-27625/com.test I/ProximityFlow: Enter Action - Lane B !!!
        07-13 14:59:41.814 27625-27625/com.test I/ProximityFlow: Enter Action - Lane B !!!
        07-13 14:59:45.155 27625-27625/com.test I/ProximityFlow: Enter Action - Lane A !!!
        07-13 14:59:45.159 27625-27625/com.test I/ProximityFlow: Enter Action - Lane A !!!
        07-13 14:59:51.180 1259-1449/? E/HwCHRWebMonitor: running processName=com.test
        07-13 14:59:55.134 27625-27625/com.test I/ProximityFlow: Enter Action - Lane A !!!
        07-13 14:59:55.137 27625-27625/com.test I/ProximityFlow: Enter Action - Lane A !!!
        07-13 14:59:55.141 27625-27625/com.test I/ProximityFlow: Enter Action - Lane A !!!
        07-13 14:59:55.145 27625-27625/com.test I/ProximityFlow: Enter Action - Lane A !!!

Raj1015120 avatar Jul 13 '18 19:07 Raj1015120

Hey @Raj1015120

As far as I understand your problem - Each start() will generate a new, separate observation process, with it's own observation handler. You can think about ProximityObserver as a builder for different scan processes.

So here is an example of launching multiple scans in the version 0.6.2:

// lets assume you have zoneA and zoneB declared
ProximityObserver.Handler handlerA = new ProximityObserverBuilder(context, credentials).build().addZone(zoneA).start();
...
// now to start observation for zoneB, you have to stop the previous one for zoneA:
handlerA.stop();
ProximityObserver.Handler handlerB = new ProximityObserverBuilder(context, credentials).build().addZone(zoneB).start();

In the version 0.6.2 it's kinda complicated to achieve this use case, but we're preparing new API for version 1.0.0 (available soon), which will be much simpler. A simple sneak-peek:

An example of launching multiple scans in the upcoming version 1.0.0:

    ProximityObserver po = new ProximityObserverBuilder(this, new EstimoteCloudCredentials("", 
    "")).build();
    
    ProximityZone zoneA = new ProximityZoneBuilder().forTag("aaa").inNearRange().build();
    ProximityZone zoneB = new ProximityZoneBuilder().forTag("bbb").inNearRange().build();
    
    ProximityObserver.Handler handlerA = po.startObserving(zoneA);
    ProximityObserver.Handler handlerB = po.startObserving(zoneB);
    
    // and then we can stop scan X
    handlerA.stop();
    // and scan Y separately:
    handlerB.stop();

Let me know what you think, and let me also now if your issue has been solved :)

Cheers, Paweł

pawelDylag avatar Jul 18 '18 08:07 pawelDylag

Thanks for the reply.

Can you please let me know when 1.0.0 is releasing ?

Raj1015120 avatar Jul 18 '18 13:07 Raj1015120

It's a matter of days, but I'll let you know :)

pawelDylag avatar Jul 18 '18 14:07 pawelDylag

Thats cool :)

Raj1015120 avatar Jul 18 '18 14:07 Raj1015120

Hi pawelDylag,

I integrated 0.6.2 version. I'm facing issues like that the beacon events are not listening properly. In the older version it was proper.

And one more question.

In my scenario, i need to set FarRange and NearRange to the single beacon. So in this this case i need to create 4 zones for the two beacons. Right ?

Ex.

ProximityZone zoneA_near= new ProximityZoneBuilder().forTag("aaa").inNearRange().build(); // zone 1 ProximityZone zoneA_far = new ProximityZoneBuilder().forTag("aaa").inFarRange().build(); //zone 2

ProximityZone zoneB_near= new ProximityZoneBuilder().forTag("bbb").inNearRange().build(); // zone 3 ProximityZone zoneB_far = new ProximityZoneBuilder().forTag("bbb").inFarRange().build(); // zone 4

Can you please conform the above or give the correct solutions.

Thanks!

Raj1015120 avatar Jul 23 '18 16:07 Raj1015120