I am developing a museum type application that when detecting a beacon at a certain distance near to a point of interest, shows me relevant information about it.
My problem is that all my beacons come by default with the same UUID, therefore I have no way to distinguish them by means of a:
if (beacon.getId1().toString().equals("iBeacon UUID here"){}
since as the estimote library says, there are only three ways to ranging a beacon form a region (https://community.estimote.com/hc/en-us/articles/203776266-What-is-a-beacon-region-):
1. With only UUID: it consists of all beacons with a given UUID. For example: a region defined with default Estimote UUID would consist of all Estimote Beacons with unchanged UUID.
2. With UUID and Major: it consists of all beacons using a specific combination of UUID and Major. For example, all Estimote Beacons with default UUID and Major set to 13579.
3. With UUID, Major and Minor: it consists of only a single beacon (Estimote Cloud prevents having two beacons with the same IDs). For example, one with default Estimote UUID, Major set to 13579 and Minor set to 2468.
I had the idea to use the next instance:
if(beacon.getBluetoothAddress().equals("iBeacon UUID here")){}
instead of the above.
But the result of using this instance is negative and the beacons are not detected correctly if i use the function "getBluetoothAddress()".
This is an example of code using "beacon.getId1().toString().equals":
beaconManager.setRangeNotifier(new RangeNotifier() {
@Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
if (beacons.size() > 0) {
String current=" ";
//EditText editText = (EditText)RangingActivity.this.findViewById(R.id.rangingText);
Beacon firstBeacon = beacons.iterator().next();
Log.e(TAG,firstBeacon.toString());
String x =firstBeacon.getId1().toString();
Double d=firstBeacon.getDistance();
// x=x.substring(24);
Log.e("Ranging","The first beacon " + firstBeacon.getId1().toString() + " is about " + firstBeacon.getDistance() + " meters away.");
if(x.equals("00112233-4455-6677-8899-aabbccddeeff") && k1!=1 && d< 5.0)
{
x = current;
monolisa_fragment fragment = new monolisa_fragment();
getFragmentManager().beginTransaction().replace(R.id.framelayout, fragment).commit();
k2=0;k3=0;k4=0;k1=1;
}
else if(x.equals("00112233-4455-6677-8899-aabbccddeeff") && k2!=1 && d< 5.0)
{
Log.e("Sure",x.toString());
kohinoor fragment=new kohinoor();
getFragmentManager().beginTransaction().replace(R.id.framelayout,fragment).commit();
k1=0;k3=0;k4=0;k2=1;
}
else if(x.equals("00112233-4455-6677-8899-aabbccddeeff") && k3!=1 && d< 5.0){
allanhills fragment =new allanhills();
getFragmentManager().beginTransaction().replace(R.id.framelayout,fragment).commit();
k1=0;k2=0;k3=1;k4=0;
}
}
}
});
try {
beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null));
} catch (RemoteException e) { }
}
but i can't use "beacon.getId1().toString().equals" because my UIID beacons, have the same UUID. And i can't use "getBluetoothAddress()", because fails and because how the estimote library says, i need the UUID of every beacon, but in my case, every beacon have the same UUID.
thanks in advance.