0

I want to display data to the textview from the database when the beacon is detected in specific distance .... the problem is it does not work or does not display anything here's my code ...

    public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {

        if (beacons.size() > 0) {           
        for (Beacon beacon: beacons) {                  
            if(beacon.getDistance() < 0.5){
              ddb();
            //Call Display data from database 
            }

Does it has something to do with ranging every second?

Is it possible to display data from the database using didRangeBeaconsInRegion?

4

1 回答 1

0

尝试添加日志行以进行故障排除,如下所示:

for (Beacon beacon: beacons) {
   Log.d(TAG, "saw beacon:"+beacon+"  with dist "+beacon.getDistance() );
   if(beacon.getDistance() < 0.5) {
      Log.d(TAG, " calling ddb");
      ddb();
      //Call Display data from database 
   }
}

检查您是否看到第一个日志行,并验证如果距离小于 0.5,则显示第二个日志行。

于 2014-10-05T01:21:11.433 回答