diff --git a/app/src/main/java/org/altbeacon/beacon/TimedBeaconSimulator.java b/app/src/main/java/org/altbeacon/beacon/TimedBeaconSimulator.java index b7b5206..617a637 100644 --- a/app/src/main/java/org/altbeacon/beacon/TimedBeaconSimulator.java +++ b/app/src/main/java/org/altbeacon/beacon/TimedBeaconSimulator.java @@ -24,7 +24,7 @@ public class TimedBeaconSimulator implements org.altbeacon.beacon.simulator.Beac * Uncomment the lines in BeaconReferenceApplication starting with: * // If you wish to test beacon detection in the Android Emulator, you can use code like this: * Then set USE_SIMULATED_BEACONS = true to initialize the sample code in this class. - * If using a bluetooth incapable test device (i.e. Emulator), you will want to comment + * If using a Bluetooth incapable test device (i.e. Emulator), you will want to comment * out the verifyBluetooth() in MonitoringActivity.java as well. * * Any simulated beacons will automatically be ignored when building for production. diff --git a/app/src/main/java/org/altbeacon/beaconreference/RangingActivity.java b/app/src/main/java/org/altbeacon/beaconreference/RangingActivity.java index c13e32d..8770daa 100644 --- a/app/src/main/java/org/altbeacon/beaconreference/RangingActivity.java +++ b/app/src/main/java/org/altbeacon/beaconreference/RangingActivity.java @@ -24,37 +24,40 @@ public class RangingActivity extends Activity implements BeaconConsumer { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - setContentView(R.layout.activity_ranging); + setContentView(R.layout.activity_ranging); beaconManager.bind(this); } + @Override protected void onDestroy() { super.onDestroy(); beaconManager.unbind(this); } + @Override protected void onPause() { - super.onPause(); - if (beaconManager.isBound(this)) beaconManager.setBackgroundMode(true); + super.onPause(); + if (beaconManager.isBound(this)) beaconManager.setBackgroundMode(true); } + @Override protected void onResume() { - super.onResume(); - if (beaconManager.isBound(this)) beaconManager.setBackgroundMode(false); + super.onResume(); + if (beaconManager.isBound(this)) beaconManager.setBackgroundMode(false); } @Override public void onBeaconServiceConnect() { beaconManager.setRangeNotifier(new RangeNotifier() { - @Override - public void didRangeBeaconsInRegion(Collection beacons, Region region) { - if (beacons.size() > 0) { - EditText editText = (EditText)RangingActivity.this - .findViewById(R.id.rangingText); - Beacon firstBeacon = beacons.iterator().next(); - logToDisplay("The first beacon "+firstBeacon.toString()+" is about "+firstBeacon.getDistance()+" meters away."); } - } + @Override + public void didRangeBeaconsInRegion(Collection beacons, Region region) { + if (beacons.size() > 0) { + //EditText editText = (EditText)RangingActivity.this.findViewById(R.id.rangingText); + Beacon firstBeacon = beacons.iterator().next(); + logToDisplay("The first beacon " + firstBeacon.toString() + " is about " + firstBeacon.getDistance() + " meters away."); + } + } }); @@ -62,13 +65,13 @@ public void didRangeBeaconsInRegion(Collection beacons, Region region) { beaconManager.startRangingBeaconsInRegion(new Region("myRangingUniqueId", null, null, null)); } catch (RemoteException e) { } } + private void logToDisplay(final String line) { - runOnUiThread(new Runnable() { - public void run() { - EditText editText = (EditText)RangingActivity.this - .findViewById(R.id.rangingText); - editText.append(line+"\n"); - } - }); + runOnUiThread(new Runnable() { + public void run() { + EditText editText = (EditText)RangingActivity.this.findViewById(R.id.rangingText); + editText.append(line+"\n"); + } + }); } }