ibeacon - identifying the beacon in the method didEnterRegion(Region region) and didExitRegion(Region region) -
want this:
public void didenterregion(region region) { if(region.getid1.equals("xxxxxxxxxxxxx")){ //display message: welcome area 1 } else if(region.getid1.equals("yyyyyyyyy")){ //display message: welcome area 2 } }
the problem when calling get.id1 value returns null , not have differentiate beacons
you need use ranging apis in order specific identifiers of visible beacons. can start ranging inside didenterregion
callback, , callback in different method identifiers. this:
public void didenterregion(region region) { beaconmanager.setrangenotifier(this); beaconmanager.startrangingbeaconsinregion(region); } public void didrangebeaconsinregion(collection<beacon> beacons, region region) { (beacon beacon: beacons) { if(beacon.getid1().tostring().equals("xxxxxxxxxxxxx")){ //display message: welcome area 1 } else if(region.getid1().tostring().equals("yyyyyyyyy")){ //display message: welcome area 2 } }
Comments
Post a Comment