2014-12-02 73 views

回答

1

您只需使用测距API以获取可见信标的特定标识符。您可以在didEnterRegion回调中开始测试,并且您将以不同的方法使用标识符进行回调。像这样:

public void didEnterRegion(Region region) { 
     beaconManager.setRangeNotifier(this); 
     beaconManager.startRangingBeaconsInRegion(region); 
} 

public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) { 
     for (Beacon beacon: beacons) { 
      if(beacon.getId1().toString().equals("xxxxxxxxxxxxx")){ 
       //display message: welcome to area 1 
      } else if(region.getId1().toString().equals("yyyyyyyyy")){ 
       //display message: welcome to area 2 
     } 
}