protected override void OnCreate(Bundle bundle) { base.OnCreate (bundle); SetContentView (Resource.Layout.Main); progressBar = FindViewById<ProgressBar> (Resource.Id.progressBar); noBeacons = FindViewById<TextView> (Resource.Id.no_beacons); ListAdapter = new BeaconAdapter (this); //create a new beacon manager to handle starting and stopping ranging beaconManager = new BeaconManager (this); //manually check for BLE var ble = Android.Content.PM.PackageManager.FeatureBluetoothLe; if (PackageManager.HasSystemFeature(ble)) { Toast.MakeText(this, "BLE not supported", ToastLength.Short).Show(); } //Validation checks if (!beaconManager.HasBluetooth) { //no bluetooth :( DisplayMessage ("No bluetooth on your device.", ":("); beaconsEnabled = false; } else if (!beaconManager.IsBluetoothEnabled) { //bluetooth is not enabled DisplayMessage ("Please turn on bluetooth.", ":("); beaconsEnabled = false; } else if (!beaconManager.CheckPermissionsAndService ()) { //issues with permissions and service DisplayMessage ("Issues with service and persmissions.", ":("); beaconsEnabled = false; } //major and minor are optional, pass in null if you don't need them beaconRegion = new Region (beaconId, uuid, major, null); //Event for when ranging happens beaconManager.Ranging += (object sender, BeaconManager.RangingEventArgs e) => RunOnUiThread (() => { if (e.Beacons.Count == 0) noBeacons.Visibility = ViewStates.Visible; else if(noBeacons.Visibility == ViewStates.Visible) noBeacons.Visibility = ViewStates.Gone; if (progressBar.Visibility == ViewStates.Visible) progressBar.Visibility = ViewStates.Invisible; ((BeaconAdapter)ListAdapter).Beacons.Clear (); ((BeaconAdapter)ListAdapter).Beacons.AddRange (e.Beacons); ((BeaconAdapter)ListAdapter).NotifyDataSetChanged (); }); //estimote loggin, optional #if DEBUG EstimoteSdk.Utility.L.EnableDebugLogging (true); #endif }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); SetContentView(Resource.Layout.Main); progressBar = FindViewById <ProgressBar> (Resource.Id.progressBar); noBeacons = FindViewById <TextView> (Resource.Id.no_beacons); ListAdapter = new BeaconAdapter(this); //create a new beacon manager to handle starting and stopping ranging beaconManager = new BeaconManager(this); //manually check for BLE var ble = Android.Content.PM.PackageManager.FeatureBluetoothLe; if (PackageManager.HasSystemFeature(ble)) { Toast.MakeText(this, "BLE not supported", ToastLength.Short).Show(); } //Validation checks if (!beaconManager.HasBluetooth) { //no bluetooth :( DisplayMessage("No bluetooth on your device.", ":("); beaconsEnabled = false; } else if (!beaconManager.IsBluetoothEnabled) { //bluetooth is not enabled DisplayMessage("Please turn on bluetooth.", ":("); beaconsEnabled = false; } else if (!beaconManager.CheckPermissionsAndService()) { //issues with permissions and service DisplayMessage("Issues with service and persmissions.", ":("); beaconsEnabled = false; } //major and minor are optional, pass in null if you don't need them beaconRegion = new Region(beaconId, uuid, major, null); //Event for when ranging happens beaconManager.Ranging += (object sender, BeaconManager.RangingEventArgs e) => RunOnUiThread(() => { if (e.Beacons.Count == 0) { noBeacons.Visibility = ViewStates.Visible; } else if (noBeacons.Visibility == ViewStates.Visible) { noBeacons.Visibility = ViewStates.Gone; } if (progressBar.Visibility == ViewStates.Visible) { progressBar.Visibility = ViewStates.Invisible; } ((BeaconAdapter)ListAdapter).Beacons.Clear(); ((BeaconAdapter)ListAdapter).Beacons.AddRange(e.Beacons); ((BeaconAdapter)ListAdapter).NotifyDataSetChanged(); }); //estimote loggin, optional #if DEBUG EstimoteSdk.Utility.L.EnableDebugLogging(true); #endif }