-1

これをしたい:

public void didEnterRegion(Region region) {
    if(region.getId1.equals("xxxxxxxxxxxxx")){
     //display message: welcome to area 1
    } else if(region.getId1.equals("yyyyyyyyy")){
     //display message: welcome to area 2
    }  
}

問題は、get.Id1 を呼び出すと、値が null を返し、ビーコンを区別する必要がないことです。

4

1 に答える 1

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
         }   
}
于 2014-12-02T16:33:38.197 に答える