I am trying to print out the list of Secure UUID beacon objects as a string. The list comes up empty if I do this with SecureRegion. It works just fine with Region (commented).
From what I read it should just be a matter of enabling the Secure UUID on the beacons through the web page, Initializing the SDK with the ID and Token and then switch from Region to SecureRegion.
What am I doing wrong?
Here is my code:
public class MainActivity extends AppCompatActivity {
private BeaconManager beaconManager;
private SecureRegion secureRegion;
//private Region region;
private String appID = "XXXX"; //from Apps>App Settings (Estimote webpage)
private String appToken = "XXXX"; //from Apps>App Settings (Estimote webpage)
public void printOut(String textToPrint){
TextView textView = (TextView)findViewById(R.id.text);
textView.setText(textToPrint);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
EstimoteSDK.initialize(getApplicationContext(), appID, appToken);
beaconManager = new BeaconManager(getApplicationContext());
beaconManager.setForegroundScanPeriod(1000, 0);
secureRegion = new SecureRegion("Secure region", null, null, null);
//region = new Region("Region", null, null, null);
beaconManager.setRangingListener(new BeaconManager.RangingListener() {
@Override
//public void onBeaconsDiscovered(Region region, List<Beacon> list) {
public void onBeaconsDiscovered(Region secureRegion, List<Beacon> list) {
Log.d("log", "onBeaconsDiscovered");
if (!list.isEmpty()) {
Log.d("log", "!list.isEmpty()" );
printOut(list.toString());
}
}
});
}
@Override
protected void onResume() {
super.onResume();
SystemRequirementsChecker.checkWithDefaultDialogs(this);
beaconManager.connect(new BeaconManager.ServiceReadyCallback() {
@Override
public void onServiceReady() {
//beaconManager.startRanging(region);
beaconManager.startRanging(secureRegion);
}
});
}
@Override
protected void onPause() {
//beaconManager.stopRanging(region);
beaconManager.stopRanging(secureRegion);
super.onPause();
}
}
Thank you!