I am using the AltBEacon Android library for developing an iBeacon app for Android devices. I am scanning for beacons, however, only two out of four
OK, I finally solved it. I ordered according to the beacon MAC address. So instead of:
public void initAll(Collection<Beacon> newBeacons) {
this.beacons.clear();
this.beacons.addAll(newBeacons);
}
I did:
public void initAll(Collection<Beacon> newBeacons) {
this.beacons.clear();
this.beacons.addAll(newBeacons);
//Sort
Collections.sort(this.beacons, new Comparator<Beacon>() {
@Override
public int compare(Beacon b1, Beacon b2) {
String mac1 = b1.getBluetoothAddress();
String mac2 = b2.getBluetoothAddress();
return mac1.compareTo(mac2);
}
});
}
A few thoughts:
Try using an off-the-shelf beacon detection program like Locate, which uses the same Android Beacon Library under the hood. If the program detects your beacons reliably, then it is probably an issue in the custom code you mention.
Make sure your beacons are transmitting frequently enough. The baseline transmission frequency is 10 Hz, but the library with default settings will pick up beacons reliably that are transmitting at least 1 Hz. Increasing the mBeaconManager.setForegroundScanPeriod();
as you describe should help this, but if the beacons are only transmitting at 0.1 Hz, then you would still have problems like you describe.
Some Android devices have a combined Wi-Fi/Bluetooth chip that prevents reliable simultaneous operation of both these radios. Try disabling Wi-Fi and see if you get the same result.