Skip to content

Commit

Permalink
Merge pull request #12 from RenniePet/Cosmetic-changes
Browse files Browse the repository at this point in the history
Cosmetic changes.
  • Loading branch information
davidgyoung committed Jun 10, 2015
2 parents 1b26bf2 + db91a28 commit af09998
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,51 +24,54 @@ 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<Beacon> 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<Beacon> 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.");
}
}

});

try {
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");
}
});
}
}

0 comments on commit af09998

Please sign in to comment.