Reputation: 608
So basicaly whant to update the layout that is a ImageView but for that need to stop ranging for the beacons, and was using beaconManager.unbind(context) and afther updating the image bind again beaconManager.bind(context) the probleam is that this context needs to be "org.altbeacon.beacon.BeaconConsumer" how do create a context of that type or isn't this way but need to call another method of beaconManager to stop the rangin and start again?
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
/*
if (beacons.size() > 0) {
Log.i(TAG, "The first beacon I see is about " + beacons.iterator().next().getDistance() + " meters away.");
}
*/
for(Beacon beacon: beacons){
double distancia = beacon.getDistance();
if(false) {
int rssi = beacon.getRssi();
int power = beacon.getTxPower();
//double distancia = beacon.getDistance();
distancias.add(beacon.getDistance());
Log.i(TAG, "Beacon detected with id1: " + beacon.getId1() + " id2:" + beacon.getId2() + " id3: " + beacon.getId3() + " distance: " + beacon.getDistance());
Log.i(TAG, "rss value->" + rssi + " power->" + power);
}
if(distancia <= 1.0){
Log.i(TAG,"esta a 1m de alcance");
/*
Bitmap bmp = BitmapFactory.decodeResource(context.getResources(),R.drawable.image5m);
Radar.setImageBitmap(bmp);
*/
}else if(distancia <= 2.0){/
Log.i(TAG,"esta a 2m de alcance");
//org.altbeacon.beacon.BeaconConsumer
//beaconManager.setAndroidLScanningDisabled(true);//setMonitorNotifier
beaconManager.unbind(ex);
Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.image10m);
Radar.setImageBitmap(bmp);
Upvotes: 0
Views: 326
Reputation: 64916
You don't need to stop beacon scanning in order to update the UI. You just need to execute the UI change on the UI thread. Like this:
runOnUiThread(new Runnable() {
public void run() {
Bitmap bmp = BitmapFactory.decodeResource(context.getResources(), R.drawable.image10m);
Radar.setImageBitmap(bmp);
}
});
Upvotes: 1