如何减少Android信标中的距离检测间隔 [英] How to reduce the range detection interval in beacon for Android

查看:125
本文介绍了如何减少Android信标中的距离检测间隔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将 Android信标库用于我的信标解决方案之一。我可以看到,如果我进入信标范围..它会调用 didEnterRegion 函数,但是当我离开信标区域时,它永远不会输入 didExitRegion 。我正在使用上面在 Android iBeacon应用中使用的代码不能在后台运行。除此之外,还有其他方法可以减少范围检测,因为我一直很频繁地获取该信息,因为如果客户在1 mt范围内输入信标,那么从逻辑上讲我想记录数据并发送一次通知。

I have using Android Beacon Library for one of my beacon solution . I can see that if I enter the beacon range ..it calls the "didEnterRegion" function but it never enter the "didExitRegion" when I go off the beacon region . I am taking the above code which I used in here Android iBeacon App not working in the background . In addition to that is there any way I can reduce the range detection because I keep on getting that very frequently because logically I want to record the data and send the notification once if customer enter beacons in 1 mt range.

推荐答案

在另一个问题中显示的代码中,didEnter Region方法禁用了 regionBootstrap.disable()如果不想禁用它,请删除该代码。

In the code shown in the other question, the didEnter Region method disables monitoring with regionBootstrap.disable() If you don't want it disabled, remove that code.

@Override
public void didEnterRegion(Region arg0) {
    Log.d(TAG, "Got a didEnterRegion call");
    // This call to disable will make it so the activity below only gets launched the first time a beacon is seen (until the next time the app is launched)
    // if you want the Activity to launch every single time beacons come into view, remove this call.
    regionBootstrap.disable();
    Intent intent = new Intent(this, MainActivity.class);
    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

    // Important:  make sure to add android:launchMode="singleInstance" in the manifest
    // to keep multiple copies of this activity from getting created if the user has
    // already manually launched the app.
    this.startActivity(intent);


}

如果您不想发送通知,直到用户< 1m,您必须使用didRangeBeaconsInRegion回调,然后仅在 beacon.getDistance< 1.0

If you don't want to send a notification until a user is < 1m, you must use the didRangeBeaconsInRegion callback, and then only fire the notification if beacon.getDistance < 1.0.

这篇关于如何减少Android信标中的距离检测间隔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆