【发布时间】:2020-03-24 01:03:36
【问题描述】:
在http://www.davidgyoungtech.com/2017/08/07/beacon-detection-with-android-8 我想做测试“新方法:定期检测”
o used program : Android Beacon Library 的参考应用程序 https://github.com/AltBeacon/android-beacon-library-reference
我在 BeaconReferenceApplication.java 中进行定期测试的设置
~~ skip ~~
beaconManager.enableForegroundServiceScanning(builder.build(), 456); // not sure to use or not
beaconManager.setEnableScheduledScanJobs(true); // Changed to true for a scheduled job
beaconManager.setBackgroundBetweenScanPeriod(0);
beaconManager.setBackgroundScanPeriod(15*60*1000); // 15min
beaconManager.setForegroundBetweenScanPeriod(0);
beaconManager.setForegroundScanPeriod(1100);
// Android limits the frequency of scheduled jobs to be at most every 15 minutes
// when an app is on the background. So any setting smaller than 15 minutes will automatically
// be converted by the operating system to run every 15 minutes
Region region = new Region("entrance",
Identifier.parse("BCFABEFC-B1F5-4836-5152-7C5412FFF9C4"),
Identifier.fromInt(20200), Identifier.fromInt(101));
Region region2 = new Region("lobby",
Identifier.parse("BCFABEFC-B1F5-4836-5152-7C5412FFF9C4"),
Identifier.fromInt(20200), Identifier.fromInt(102));
List<Region> regions = new ArrayList<>();
regions.add(region);
regions.add(region2);
regionBootstrap = new RegionBootstrap(this, regions);
~~ skip ~~
问题(1):使用上述设置运行时,我等待超过 25 分钟,调试时没有任何结果。 后台定期 ScheduledScanJobs 怎么办?
【问题讨论】:
-
Tr beaconManager.setDebug(true);然后,您应该每隔约 15 分钟看到一次来自您应用的日志。
-
davidyoung,谢谢。
标签: android background bluetooth-lowenergy beacon scanning