java #Beacon Scan.java
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了java #Beacon Scan.java相关的知识,希望对你有一定的参考价值。
http://stackoverflow.com/questions/26607423/detect-ibeacon-using-altbeacon-library
public class RangingActivity extends Activity implements BeaconConsumer {
protected static final String TAG = "RangingActivity";
private static final String UUID = "XXXXXXXXXXXXXXXXXXXX";
private BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_ranging);
beaconManager.bind(this);
}
@Override
protected void onDestroy() {
super.onDestroy();
beaconManager.unbind(this);
}
@Override
public void onBeaconServiceConnect() {
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
Log.i(TAG, "The first beacon I see is about "+beacons.iterator().next().getDistance()+" meters away.");
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", Identifier.parse(UUID), null, null));
} catch (RemoteException e) { }
beaconManager.getBeaconParsers().add(new BeaconParser()
.setBeaconLayout("m:2-3=0215,i:4-19,i:20-21,i:22-23,p:24-24"));
}
}
以上是关于java #Beacon Scan.java的主要内容,如果未能解决你的问题,请参考以下文章
Belisha Beacon Java Program 按钮查询
802.11 ------ Beacon帧Beacon IntervalTBTTListen IntervalTIMDTIM
Estimote Beacon - 如何将 EstimoteTelemetry 与 Beacon 匹配
有关802.11的Beacon帧
当设备已经在 Beacon 范围内时无法检测到 Beacon 然后我们打开蓝牙 & 应用程序被杀死
ZigBee网络信标(Beacon)和非信标(Non-beacon)两种工作模式