Hello,
I have the following code which running fine on Android studio 2.2 and Samsung S5.
Now I use Android 3.5 and Samsung A20.
The same code detect only one beacon.Have you already encounter this issue but the Estimote app detect all of them.
I really need help.
Below is the the code.
private final double MAX_BEACON_DISTANCE = 100;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState)
beaconManager = new BeaconManager(this);
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
beaconManager.startRanging(region);
}
});
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
public void onBeaconsDiscovered(Region region, List<Beacon> list) {
Integer major = 0;
Integer minor = 0;
distanceToClosestBeacon = MAX_BEACON_DISTANCE;
for (Beacon rangedBeacon : list) {
// Estimote function to compute distance
// based on signal's strength
Double distanceToThisBeacon = Utils.computeAccuracy(rangedBeacon);
if (distanceToThisBeacon <= distanceToClosestBeacon) {
distanceToClosestBeacon = distanceToThisBeacon;
major = rangedBeacon.getMajor(); // that's how we can get beacon's major ID
minor = rangedBeacon.getMinor(); // and that's how we can get it's minor ID
}
}
if(major==majorvalue1stbeacon)
{//Treatment}
if(major==majorvalue2stbeacon)
{//Treatment}
if(major==majorvalue3stbeacon)
{//Treatment}
});
region = new Region("ranged region", UUID.fromString(stringUUID), null, null);
}