估计接近信标连续进入退出警报

时间:2019-04-16 09:36:40

标签: beacon proximity estimote

我正在使用Estimote邻近信标检测到存在。问题是即使手机距离信标非常近,我也会收到多个进入/退出警报。任何人都知道如何解决此问题?我从Estimote开发人员门户使用了以下代码。

this.proximityObserver =
            new ProximityObserverBuilder(getApplicationContext(), 
cloudCredentials)
                    .onError(new Function1<Throwable, Unit>() {
                        @Override
                        public Unit invoke(Throwable throwable) {
                            Log.e("app", "proximity observer error: " + 
throwable);
                            return null;
                        }
                    })
                    .withBalancedPowerMode()
                    .build();

    final ProximityZone zone = new ProximityZoneBuilder()
            .forTag("LDMC")
            .inNearRange() //inCustomRange(3.0) //inNearRange()
            .onEnter(new Function1<ProximityZoneContext, Unit>() {
                @Override
                public Unit invoke(ProximityZoneContext context) {
                    String deskOwner = 
context.getAttachments().get("Room");
                    proximity = true;
                    Toast.makeText(MainActivity.this, "In Range.", 
Toast.LENGTH_SHORT).show();
                    Log.d("app", "Welcome to " + deskOwner + "room.");

                    return null;
                }
            })
            .onExit(new Function1<ProximityZoneContext, Unit>() {
                @Override
                public Unit invoke(ProximityZoneContext context) {
                    proximity = false;
                    Toast.makeText(MainActivity.this, "Out of Range.", 
Toast.LENGTH_SHORT).show();
                    Log.d("app", "Bye bye, come again!");
                    return null;
                }
            })
            .build();

0 个答案:

没有答案