Hi,
I’m doing some testing with the Estimote iBeacons (proximity) and I’m using Visual Studio 2017 with the SDK wrapper / component from Xamarin. The development is done for Android.
My problem is that I can’t trigger the BeaconEnteredRegion and BeaconExitedRegion events. I can track the program and see that the OnServiceReady and OnResume events are triggered, so I guess everything is good to go?
The program compiles without error and is tested on a Samsung Galaxy S5.
This is my code:
using Android.App;
using Android.Widget;
using Android.OS;
using EstimoteSdk.Service;
using EstimoteSdk.Observation.Region.Beacon;
using EstimoteSdk.Common.Requirements;
using EstimoteTesting;
namespace EstimoteTesting
{
[Activity(Label = "Test Estimote", MainLauncher = true)]
public class MainActivity : Activity, BeaconManager.IServiceReadyCallback
{
static readonly string UUID = "B9407F30-F5F8-466E-AFF9-25556B57FE6D";
BeaconManager _beaconManager;
BeaconRegion _region;
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Main);
//Reference the controls
Button getBeacons = FindViewById<Button>(Resource.Id.btnGetBeacons);
EditText beaconList = FindViewById<EditText>(Resource.Id.lstBeacons);
_beaconManager = new BeaconManager(Application.Context);
_region = new BeaconRegion(”A region”, UUID);
_beaconManager.SetBackgroundScanPeriod(6000, 0);
_beaconManager.BeaconEnteredRegion += (sender, e) => {
beaconList.Append("Beacon has ENTERED the region !");
};
_beaconManager.BeaconExitedRegion += (sender, e) => {
beaconList.Append("Beacon has LEFT the region");
};
}
protected override void OnResume()
{
base.OnResume();
bool TheResult = SystemRequirementsChecker.CheckWithDefaultDialogs(this);
_beaconManager.Connect(this);
}
public void OnServiceReady()
{
// This method is called when BeaconManager is up and running.
_beaconManager.StartMonitoring(_region);
}
protected override void OnDestroy()
{
// Make sure we disconnect from the Estimote.
_beaconManager.Disconnect();
base.OnDestroy();
}
}
}