【问题标题】:How to increase the delay in the data of the region notifier?如何增加区域通知器的数据延迟?
【发布时间】:2017-07-17 11:11:52
【问题描述】:

我已将 Android 信标库用于我的信标解决方案之一。有没有办法延迟范围通知器生成的数据,因为它非常频繁地提供数据。 下面是我所指的代码。要查看完整代码,您可以转到此线程“Android iBeacon App not working in the background”

@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {

    if(beacons.size() > 0) {
        for (Beacon beacon : beacons) {
            if (beacon.getDistance() < 1.0) {
                Log.d(TAG, "I see a beacon transmitting a : " +
                        " approximately " + beacon.getDistance() + " meters away.");

                Log.d(TAG, "BEACON DATA : " +beacon.getBluetoothAddress()+":"+beacon.getBluetoothName()+":"+beacon.getId1());

                showNotification("Treewalker","You are near beacon range");
                Intent intent = new Intent(this,MainActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                this.startActivity(intent);


            }


        }
    }
}

【问题讨论】:

    标签: android ibeacon ibeacon-android beacon android-ibeacon


    【解决方案1】:

    有两种方法可以帮助你

    mBeaconManager.setBackgroundBetweenScanPeriod(10000);
    mBeaconManager.setForegroundBetweenScanPeriod(10000);
    

    查看官方javadocs了解详情

    【讨论】:

    • 感谢您的快速回复。如果客户已经通过该地区,我是否可以只发送一次通知?
    • 你可以使用mBeaconManager.stopRangingBeaconsInRegion(YOUR_REGION);
    • 请注意,如果您在开始扫描后更改扫描周期,则需要致电beaconManager.updateScanPeriods(); 使更改生效
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-11
    • 2017-06-12
    • 1970-01-01
    • 2013-12-12
    • 2015-10-26
    相关资源
    最近更新 更多