AltBeacon 次要和主要

AltBeacon Minor & Major

当检测到信标(背景)时,我们如何在监控模式中获得次要和主要?

我检查了 https://altbeacon.github.io/android-beacon-library/samples.html 但没有找到解决方案。

您可以使用此示例 code.Ranging 示例 Code.Listed 信标 major,minor ex。 this

监控 API 未 return 检测到匹配信标 的确切标识符。它们仅 return 对用于监视的 Region 对象的引用,如果它包含标识符的空值(通配符),那么您将无法确切知道看到了哪些信标标识符。

当您需要了解这些标识符时,标准方法是使用由beaconManager.startRangingBeaconsInRegion(region) 触发的范围APIs。这些 API 的回调是 didRangeBeaconsInRegion(Region region, Collection<Beacon>),它为您提供了在上次扫描间隔中匹配的每个信标的列表。

您可以在此处的同一示例页面中查看如何使用范围的示例:https://altbeacon.github.io/android-beacon-library/samples.html

这个库看起来像是信标检测库的通用形式。它不仅适用于 iBeacons。所以你不能直接得到 Major 和 Minor。但是有一个信标解析器class可以用来完成这个任务。Link 示例:

 BeaconManager.getBeaconParsers().add(new BeaconParser()
  .setBeaconLayout("m:2-3=beac,i:4-19,i:20-21,i:22-23,p:24-24,d:25-25"));