Reputation: 51
When we want to get minor and major with this code we get null in both , but in log we get the values :
when we want to get minor and major with this code we get null in both , but in log we get the values :
Beacon firstBeacon = beacons.iterator().next();
Log.i(TAG,"The first beacon " + firstBeacon.toString() + " is about " + firstBeacon.getDistance() + " meters away.");
Log.i(TAG, "The first beacon I see has minor id "+beacons.iterator().next().getId3());
Log.i(TAG, "The first beacon I see has major id "+beacons.iterator().next().getId2());
String minor = beacons.iterator().next().getId3();
String major = beacons.iterator().next().getId2();
Upvotes: 0
Views: 445
Reputation: 1427
You can try
ArrayList<Beacon> mylist = new ArrayList<Beacon>(beacons);
for (int j = 0; j < mylist.size(); j++) {
String rangedUUID = mylist.get(j).getId1().toString();
String rangedMajor = mylist.get(j).getId2().toString();
String rangedMinor = mylist.get(j).getId3().toString();
}
or you can replace this
String minor = beacons.iterator().next().getId3();
String major = beacons.iterator().next().getId2();
with
String minor = firstBeacon.getId3();
String major = firstBeacon.getId2();
Because
beacons.iterator().next()
give next beacon
Upvotes: 2