Example #1
0
 /// <summary>Raises the <see cref="BluetoothStateChanged" /> event.</summary>
 /// <param name="sender">The object that raised the event.</param>
 /// <param name="btState">Current state of the Bluetooth module</param>
 protected virtual void OnBluetoothStateChanged(Bluetooth sender, BluetoothState btState)
 {
     if (_onBluetoothStateChanged == null)
     {
         _onBluetoothStateChanged = OnBluetoothStateChanged;
     }
     BluetoothStateChanged?.Invoke(sender, btState);
 }
Example #2
0
        public override void OnReceive(Context context, Intent intent)
        {
            string action = intent.Action;

            if (action.Equals(BluetoothAdapter.ActionStateChanged))
            {
                var state = intent.GetIntExtra(BluetoothAdapter.ExtraState, BluetoothAdapter.Error);
                if (state == (int)State.Off)
                {
                    BluetoothStateChanged?.Invoke(State.Off, new EventArgs());
                }
                else if (state == (int)State.On)
                {
                    BluetoothStateChanged?.Invoke(State.On, new EventArgs());
                }
            }
        }