Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

Testing Estimote - triggers not fired.

$
0
0

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();
        }

    }
}

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>