I use these method to detect beacons
@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) { }
}
I am using two beacon, one estimoe beacon and one virtual beacon simulated with bluez. The UUID of the beacons in the output were changed.The detection is working but sometimes as you can see in the output, the onBeaconServiceConnect function is called with only one detected beacon or even with none of them. I know that I can wait like 10 second and if the beacon is not detected anymore I can assume that it's not in the area anymore but is there an efficient way to detect as soon as possible when a beacon is detected or not detected anymore ?
-------------------------------
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
Quickly reporting a beacon detection is easy -- as soon as the radio decodes a packet, you report the detection. In the background on Android 5+ this is exactly what the Android Beacon Library does.
Reporting that a beacon is no longer detected is harder. The fundamental issue is that there is no way to know instantly when a beacon goes out of range. Beacon transmissions are not a constant signal -- they pulse packets between periods of transmission silence. So determining that a beacon is not present comes down seeing some time interval in which no beacon packets are detected.
Mobile devices also do not detect 100% of beacon packets that are sent. Radio noise, weak signals and collisions can lead to packet losses. At short distances of a few meters, perhaps 80-90 percent of packets are received. At greater distances near the maximum BLE transmission range of 40-50 meters, that percentage drops to nearly zero.
Beacon detection frameworks therefore must have a time interval since last detection that says is statistically likely that a beacon is no longer nearby. When no beacon packets have been detected in this interval, the event fires.
It is possible to reduce this interval, but there are tradeoffs. The shorter you make the interval, the more likely it will be that you will get false exit callbacks. These mean that you get an exit callback, followed quickly by a new entry callback when a packet is next detected.
Deciding how long to wait for a beacon packet before triggering an exit is highly influenced by beacon packet transmission rates.
The most common transmission frequency is 10 Hz, meaning 10 packets are transmitted each second. But many manufacturers build beacons that transmit less frequently or build beacons that can be configured to transmit less frequently to save battery power. It is common for battery beacons to be shipped in a configuration that transmits at only 1 Hz. Some beacons transmit only once every 5 seconds or less.
Apple's CoreLocation
framework uses 30 seconds as the beacon region exit interval for both ranging and monitoring purposes. During ranging, if the beacon has not been detected in the past second, it reports an proximity of "unknown". This is not configurable.
The Android Beacon Library also uses 30 seconds as the default beacon region exit interval (this is configurable), and it does not include a beacon in the ranging list if it has not been detected in the past ranging period (configurable, but defaulting to 1.1 secs.)
Based on the log output shown, it appears that the beacon with Major: 39749 Minor: 25488 is either advertising at a low frequency of less than 1 Hz or has a low signal level making most of its packets be lost. If you increase its transmission rate, detections will be more reliable.
Since you are using the Android Beacon Library, you have the option of extending the ranging scan interval to be longer than the default 1.1 seconds, so the detections appear more steady. You can do this by calling beaconManager.setForegroundScanInterval(5000l);
to set it to 5 seconds.
Another option is to add a software filter to remember if a beacon was seen in the past few seconds and then report that it is still visible even though the library says it is not. This has the advantage of not slowing down initial detections beyond 1.1 seconds.