设置android刷新率,Android信标库设置刷新率

我正在尝试提高我的Beacon应用程序的更新率。目前,信标本身被设置为“我在这里!” - 速率为500ms。Android信标库设置刷新率

我看到Android信标库的默认刷新率设置为1100毫秒,这似乎是这种情况。

但似乎我无法更改此刷新率(Android信标库)。我想:

@Override

public void onBeaconServiceConnect() {

// create the necessary region for the Beacon App and give it the Sensorberg UUIDs or parse "null" if it doesn't matter

final Region region = new Region("myBeacons", null, null, null);

beaconManager.setForegroundScanPeriod(200l); // 200ms

beaconManager.setForegroundBetweenScanPeriod(0l); // 0ms

try {

beaconManager.updateScanPeriods();

} catch (RemoteException e) {

Log.e(TAG, "Cannot talk to service" + (e));

}

的onCreate方法首先创建管理器的一个实例beaconManager = BeaconManager.getInstanceForApplication(本);

然后设置距离检测模式为BeaconManager.setRssiFilterImplClass(ArmaRssiFilter.class);。 。

我建立之后所述信标数据布局beaconManager.getBeaconParsers()添加(新BeaconParser() .setBeaconLayout(“M:2-3 = 0215,I:4-19,I:20-21 ,I:22-23,p:24-24,d:25-25" ));。

现在我通过beaconManager.bind(this)启动管理器; 然后OnCreate方法关闭。

后来我onBeaconServiceConnect方法我试图加快刷新率(上面张贴的代码),但它似乎没有任何更改时运行应用程序。它仍然超过1秒。此外,我的logCat中没有“无法调用服务”。

有人可以帮助我更频繁地设置Android Beacon库中扫描的刷新率吗?谢谢! :)

更新:我没有调试我的应用程序,在这里是logcat的日志:

它与所有日志的文本文件。

**更新2:**正如@davidgyoung提供的答案一样,更新速率正确更改为200ms。我每次在setRangeNotifier中检测到信标时都会执行控制台日志,在onBeaconServiceConnect方法中调用此方法,并且您可以清楚地告诉时间戳记此控制台日志太慢(约一秒)。它应该至少每隔500ms(因为这是信标的设置)。那么,有什么原因可能会放慢这一过程?我有一个银河S5新星应该是相当好的,应用程序只是很小。

控制台校验码:这个代码的

// check for available data from the Beacons

beaconManager.setRangeNotifier(new RangeNotifier() {

@Override

public void didRangeBeaconsInRegion(Collection beacons, Region region) {

// for each Beacon print the data and do the following functions

for(final Beacon oneBeacon : beacons) {

Log.d(TAG, "distance: " + oneBeacon.getDistance() + "id: " + oneBeacon.getId1() + "/" + oneBeacon.getId2() + "/" + oneBeacon.getId3());

日志输出:

06-18 14:19:27.101 19937-20235/de.mediatoni.beaconProto3 d/BeaconService:检测到的信标:id1:73676723-7400-0000-ffff-0000ffff0001 id2:3788 id3:2001 06-18 14:19:27.891 19937-20275/de.mediatoni。beaconProto3 D/BeaconService:检测到信标:id1:73676723-7400-0000-ffff-0000ffff0000 id2:3788 id3:2000 06-18 14:19:28.111 19937-20300/de.mediatoni.beaconProto3 D/BeaconService:检测到信标: id1:73676723-7400-0000-ffff-0000ffff0002 id2:3788 id3:2002 06-18 14:19:28.701 19937-20302/de.mediatoni.beaconProto3 D/BeaconService:检测到信标:id1:73676723-7400-0000- ffff-0000ffff0000 id2:3788 id3:2000 06-18 14:19:28.811 19937-20337/de.mediatoni.beaconProto3 D/BeaconService:检测到信标:id1:73676723-7400-0000-ffff-0000ffff0001 id2:3788 id3:2001 06-18 14:19:28.821 19937-20338/de.mediatoni.beaconProto3 D/BeaconService:检测到信标:id1:73676723-7400-0000-ffff-0000ffff0002 id2:3788 id3:2002

2016-06-16

olop01

+0

你玩过扫描设置吗? 'ScanSettings.Builder scanSettingsBuilder = new ScanSettings.Builder(); scanSettingsBuilder.setReportDelay(0); scanSettingsBuilder.setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY);' –

+0

我不知道为什么这不起作用。它看起来应该像我一样。如果您使用beaconManager.setDebug(true)打开调试日志记录,然后在更改扫描时间间隔之前和之后捕获LogCat输出30秒左右,可能会有所帮助。如果你可以做到这一点,并在某处发布日志,我会看看。 –

+0

@davidgyoung我用日志更新了帖子。它说:** 06-17 19:03:13.641 10161-10161/de.mediatoni.beaconProto3 D/BeaconManager:将扫描周期更新为200,0 ** –

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值