【问题标题】:How to Run for Periodic Detections with Android Beacon Library如何使用 Android 信标库运行定期检测
【发布时间】: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


【解决方案1】:

这些将有助于安排扫描

  beaconManager.setEnableScheduledScanJobs(true); # with this marked true , you will not be able to run background service

  beaconManager.setBackgroundBetweenScanPeriod(200l);  beaconManager.setBackgroundScanPeriod(1100);

前台扫描周期

   beaconManager.setForegroundScanPeriod(100);beaconManager.setEnableScheduledScanJobs(true);  

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多