1
我希望应用只在“立即”范围内看到信标。在其中一篇文章中(我没有链接),我读了诸如Immediate/Near/Far之类的字符串与altbeacon或其他类似的字符,因此建议使用beacon.getDistance() < 0.5
来实现远程信标。但不幸的是我没有任何线索如何实现。Altbeacon - 仅在IMMEDIATE范围内检测到信标,并丢弃此范围以外的任何信息
我试着用一篇文章提出的以下代码来找到最短距离的信标,但似乎无法正常工作(最有可能是因为波动的rssi和通过将信标保持在相距很近的距离进行测试)知道为什么他们要min = Integer.MAX_VALUE
....但我期待ATLEAST一些结果)
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
Object[] beaconArray = beacons.toArray();
//find the beacon with shortest distance
int count=-1; //when no beacon is there
int min = Integer.MAX_VALUE;
for (int i=0; i < beaconArray.length; i++){
int d=((Beacon)beaconArray[i]).getRssi();
if(d < min){
min=d;
count=i; //1st beacon in the array
}
}
//play with the beacon at the shortest distance
uuid = ((Beacon)beaconArray[count]).getId1().toString();
一些技巧将是一个祝福我。