我使用这些方法来检测信标
@Override
public void onBeaconServiceConnect() {
BeaconManager beaconManager = BeaconManager.getInstanceForApplication(this);
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
Log.i("MainA","-------------------------------");
for (Beacon beacon : beacons) {
Log.i("MainActivity", "I see a beacon"+beacon.getId1()+" Major: " + beacon.getId2()+" Minor: "+beacon.getId3());
}
Log.i("MainA","-------------------------------");
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) { }
}
我正在使用两个信标,一个estimoe信标和一个用bluez模拟的虚拟信标。输出中信标的UUID已更改。检测正在运行,但有时您可以在输出中看到,仅使用一个检测到的信标调用onBeaconServiceConnect函数,甚至不调用它们。我知道我可以等待10秒钟,如果不再检测到信标,我可以认为它不再在该区域内,但是当检测到信标时,是否有一种有效的方法来检测信标检测到了吗?
-------------------------------
04-24 17:10:33.021 2041-3467/com.example.kev.altbeacon I/MainActivity: I see a beaconhgfhgvgv-h7h5-88h9-kjh3-7554hjvv8 Major: 39749 Minor: 25488
04-24 17:10:33.021 2041-3467/com.example.kev.altbeacon I/MainActivity: I see a beacon123456-hfhj-JJJJ-87j8-jjkzbzkf876 Major: 4369 Minor: 4369
04-24 17:10:33.021 2041-3467/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:33.101 2041-2053/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:33.101 2041-2053/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:34.161 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:34.161 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:34.161 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:34.171 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:34.171 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:34.181 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:34.181 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:34.181 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:34.231 2041-3131/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:34.341 2041-3510/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:34.351 2041-3510/com.example.kev.altbeacon I/MainActivity: I see a beaconhgfhgvgv-h7h5-88h9-kjh3-7554hjvv8 Major: 39749 Minor: 25488
04-24 17:10:34.351 2041-3510/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:35.411 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:35.411 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:35.411 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:35.461 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:35.461 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:35.461 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:35.471 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:35.471 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:35.511 2041-3131/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:35.531 2041-3562/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:35.531 2041-3562/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:36.011 2041-2054/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:36.011 2041-2054/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:36.641 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:36.641 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:36.641 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:36.651 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:36.651 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:36.651 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:36.661 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:36.661 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:36.701 2041-2053/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:36.711 2041-3628/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:36.711 2041-3628/com.example.kev.altbeacon I/MainActivity: I see a beaconhgfhgvgv-h7h5-88h9-kjh3-7554hjvv8 Major: 39749 Minor: 25488
04-24 17:10:36.711 2041-3628/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:37.821 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:37.821 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:37.821 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:37.841 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:37.841 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:37.841 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:37.841 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:37.841 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:37.891 2041-2053/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:37.901 2041-3681/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:37.901 2041-3681/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:39.071 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:39.071 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:39.071 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:39.091 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:39.101 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:39.111 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:39.111 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:39.111 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:39.161 2041-2053/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:39.171 2041-3724/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:39.171 2041-3724/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:40.321 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:40.321 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:40.321 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:40.401 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:40.401 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:40.401 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:40.411 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:40.411 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:40.451 2041-2054/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:40.461 2041-3770/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:40.461 2041-3770/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:40.761 2041-2053/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:40.761 2041-2053/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:41.591 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:41.591 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:41.591 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:41.661 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:41.661 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:41.661 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:41.661 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:41.661 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:41.711 2041-2053/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:41.721 2041-3819/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:41.721 2041-3819/com.example.kev.altbeacon I/MainActivity: I see a beaconhgfhgvgv-h7h5-88h9-kjh3-7554hjvv8 Major: 39749 Minor: 25488
04-24 17:10:41.721 2041-3819/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:42.861 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:42.871 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:42.871 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:42.881 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:42.891 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:42.891 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:42.891 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:42.891 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:42.941 2041-2054/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:43.071 2041-3865/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:43.071 2041-3865/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:43.631 2041-2053/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:43.631 2041-2053/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:44.111 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:44.111 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:44.111 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:44.131 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:44.131 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:44.131 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:44.131 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:44.131 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:44.181 2041-3131/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:44.201 2041-3927/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:44.201 2041-3927/com.example.kev.altbeacon I/MainActivity: I see a beaconhgfhgvgv-h7h5-88h9-kjh3-7554hjvv8 Major: 39749 Minor: 25488
04-24 17:10:44.201 2041-3927/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:44.621 2041-2054/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:44.621 2041-2054/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:45.321 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:45.321 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:45.321 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:45.331 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:45.331 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:45.331 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:45.331 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:45.341 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:45.381 2041-2054/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:45.401 2041-4042/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:45.401 2041-4042/com.example.kev.altbeacon I/MainActivity: I see a beaconhgfhgvgv-h7h5-88h9-kjh3-7554hjvv8 Major: 39749 Minor: 25488
04-24 17:10:45.401 2041-4042/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:45.531 2041-2053/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:45.531 2041-2053/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:46.511 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:46.511 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:46.511 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:46.521 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:46.521 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:46.521 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:46.521 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:46.521 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:46.571 2041-3131/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:46.581 2041-4080/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:46.581 2041-4080/com.example.kev.altbeacon I/MainActivity: I see a beaconhgfhgvgv-h7h5-88h9-kjh3-7554hjvv8 Major: 39749 Minor: 25488
04-24 17:10:46.581 2041-4080/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:47.701 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:47.701 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:47.701 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:47.711 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:47.721 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:47.721 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:47.721 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:47.721 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:47.771 2041-3131/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:47.781 2041-4116/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:47.781 2041-4116/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:48.891 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:48.891 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:48.891 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:48.911 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:48.911 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:48.911 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:48.921 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:48.921 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:48.961 2041-2053/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:48.971 2041-4169/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:48.971 2041-4169/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:50.081 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:50.081 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:50.081 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:50.091 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:50.101 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:50.101 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:50.101 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:50.101 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:50.151 2041-2053/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:50.161 2041-4218/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:50.161 2041-4218/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:51.271 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:51.271 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:51.271 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:51.281 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:51.281 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:51.291 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:51.291 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:51.291 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:51.331 2041-2053/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:51.351 2041-4281/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:51.351 2041-4281/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:51.561 2041-2054/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:51.561 2041-2054/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:52.451 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:52.461 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:52.461 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:52.461 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:52.471 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:52.471 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:52.471 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:52.471 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:52.521 2041-3131/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:52.571 2041-4338/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:52.571 2041-4338/com.example.kev.altbeacon I/MainActivity: I see a beacon123456-hfhj-JJJJ-87j8-jjkzbzkf876 Major: 4369 Minor: 4369
04-24 17:10:52.571 2041-4338/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:52.871 2041-2053/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:52.871 2041-2053/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:53.191 2041-3131/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:53.191 2041-3131/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:53.671 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:53.671 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:53.671 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:53.691 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:53.691 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:53.691 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:53.691 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:53.691 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:53.741 2041-2053/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:53.761 2041-4376/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:53.761 2041-4376/com.example.kev.altbeacon I/MainActivity: I see a beacon123456-hfhj-JJJJ-87j8-jjkzbzkf876 Major: 4369 Minor: 4369
04-24 17:10:53.761 2041-4376/com.example.kev.altbeacon I/MainActivity: I see a beaconhgfhgvgv-h7h5-88h9-kjh3-7554hjvv8 Major: 39749 Minor: 25488
04-24 17:10:53.761 2041-4376/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:54.111 2041-2054/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:54.111 2041-2054/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:54.141 2041-2053/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:54.141 2041-2053/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:54.861 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:54.871 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:54.871 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:54.881 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:54.881 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:54.891 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:54.891 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:54.891 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:54.931 2041-2054/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:54.951 2041-4438/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:54.951 2041-4438/com.example.kev.altbeacon I/MainActivity: I see a beaconhgfhgvgv-h7h5-88h9-kjh3-7554hjvv8 Major: 39749 Minor: 25488
04-24 17:10:54.951 2041-4438/com.example.kev.altbeacon I/MainActivity: I see a beacon123456-hfhj-JJJJ-87j8-jjkzbzkf876 Major: 4369 Minor: 4369
04-24 17:10:54.951 2041-4438/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:55.081 2041-3131/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:55.081 2041-3131/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:55.431 2041-2054/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:55.431 2041-2054/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:56.071 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:56.071 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:56.071 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:56.101 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:56.101 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:56.101 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:56.101 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:56.101 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:56.151 2041-3131/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:56.201 2041-4523/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:56.201 2041-4523/com.example.kev.altbeacon I/MainActivity: I see a beacon123456-hfhj-JJJJ-87j8-jjkzbzkf876 Major: 4369 Minor: 4369
04-24 17:10:56.201 2041-4523/com.example.kev.altbeacon I/MainActivity: I see a beaconhgfhgvgv-h7h5-88h9-kjh3-7554hjvv8 Major: 39749 Minor: 25488
04-24 17:10:56.201 2041-4523/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:56.721 2041-3131/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:56.721 2041-3131/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:57.341 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:57.341 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:57.341 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:57.401 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:57.411 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:57.411 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:57.411 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:57.411 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:57.451 2041-3131/com.example.kev.altbeacon D/BluetoothLeScanner: onClientRegistered() - status=0 clientIf=7
04-24 17:10:57.471 2041-4575/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:57.471 2041-4575/com.example.kev.altbeacon I/MainActivity: I see a beacon123456-hfhj-JJJJ-87j8-jjkzbzkf876 Major: 4369 Minor: 4369
04-24 17:10:57.471 2041-4575/com.example.kev.altbeacon I/MainA: -------------------------------
04-24 17:10:57.931 2041-2054/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:57.931 2041-2054/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:57.991 2041-3131/com.example.kev.altbeacon D/ScanRecord: parseFromBytes
04-24 17:10:57.991 2041-3131/com.example.kev.altbeacon D/ScanRecord: first manudata for manu ID
04-24 17:10:58.591 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:58.591 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:58.591 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Stop Scan
04-24 17:10:58.611 2041-2041/com.example.kev.altbeacon D/BluetoothLeScanner: Start Scan
04-24 17:10:58.611 2041-2041/com.example.kev.altbeacon D/BluetoothAdapter: STATE_ON
04-24 17:10:58.611 2041-2041/com.example.kev.altbeacon D/Bluet
答案 0 :(得分:1)
快速报告信标检测很容易 - 只要无线电解码数据包,就会报告检测结果。在Android 5+的背景下,这正是Android Beacon Library所做的。
报告不再检测到信标更难。根本问题是无法立即知道信标何时超出范围。信标传输不是恒定信号 - 它们在传输静默期间脉冲数据包。因此,确定信标不存在会看到一些时间间隔,其中没有检测到信标数据包。
移动设备也无法检测到100%的信标数据包被发送。无线电噪声,弱信号和冲突可能导致数据包丢失。在几米的短距离内,可能会收到80-90%的数据包。在最大BLE传输范围40-50米附近的较大距离处,该百分比下降到接近零。
因此,信标检测框架必须具有自上次检测以来的时间间隔,该时间间隔在统计上可能表明信标不再在附近。如果在此间隔内未检测到信标数据包,则会触发事件。可以减少这个间隔,但需要权衡。您创建间隔的时间越短,您获得错误退出回调的可能性就越大。这意味着您将获得一个退出回调,然后在下次检测到数据包时快速进行新的条目回调。
决定在触发退出之前等待信标数据包的时间长度受信标数据包传输速率的影响很大。
最常见的传输频率是10 Hz ,这意味着每秒传输10个数据包。但是,许多制造商制造的信标传输频率较低,或构建信标,可配置为频率较低,以节省电池电量。电池信标通常以仅以1Hz发送的配置运输。 有些信标每5秒或更短时间只发送一次。
Apple的CoreLocation
框架使用30秒作为信标区域退出间隔,用于测距和监控目的。在测距期间,如果在过去的第二秒中未检测到信标,则报告“未知”的接近度。这是不可配置的。
Android Beacon Library也使用30秒作为默认信标区域退出间隔(这是可配置的),如果在过去的测距期间未检测到它,则它不包括测距列表中的信标(可配置,但是默认为1.1秒。)
根据显示的日志输出,似乎具有Major的信标:39749 Minor:25488要么以低于1 Hz的低频广告,要么具有低信号电平它的包丢失了。如果提高其传输速率,检测将更可靠。
由于您使用的是Android Beacon Library,可以选择延长测距扫描间隔,使其长度超过默认的1.1秒,因此检测结果会更稳定。您可以通过调用beaconManager.setForegroundScanInterval(5000l);
将其设置为5秒来执行此操作。
另一种选择是添加软件过滤器以记住过去几秒内是否看到过信标,然后报告它仍然可见,即使图书馆说它不是。这样做的好处是不会使初始检测速度减慢超过1.1秒。