如何增加区域通知器数据的延迟? [英] How to increase the delay in the data of the region notifier?

查看:90
本文介绍了如何增加区域通知器数据的延迟?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经将Android Beacon库用于我的一个beacon解决方案。是否有一种方法可以延迟范围通知程序产生的数据,因为它经常提供数据。
下面是我所指的代码。要查看完整的代码,您可以转到该线程 Android iBeacon应用

I have using Android Beacon Library for one of my beacon solution .Is there a way put a delay in data produced by the range notifier because it is giving data very frequently . Below is the code which I am referring to. To see complete code you can go to this thread "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);


            }


        }
    }
}


推荐答案

有两种方法可以帮助您

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

检查官方 javadocs 了解详情

这篇关于如何增加区域通知器数据的延迟?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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