예제 #1
0
 /// <summary>
 /// Unregisters the receiver.
 /// </summary>
 public void UnregisterReceiver()
 {
     if (_receiver != null)
     {
         _activity.ApplicationContext.UnregisterReceiver(_receiver);
         _receiver = null;
     }
 }
예제 #2
0
        /// <summary>
        /// Registers the receiver for scanning and pairing operations.
        /// </summary>
        public void RegisterReceivers()
        {
            // Register for broadcasts when a device is discovered
            _receiver = new BTReceiver();
            var filter = new IntentFilter(BluetoothDevice.ActionFound);

            _activity.ApplicationContext.RegisterReceiver(_receiver, filter);

            // Register for broadcasts when discovery has finished
            filter = new IntentFilter(BluetoothAdapter.ActionDiscoveryFinished);
            _activity.ApplicationContext.RegisterReceiver(_receiver, filter);

            filter = new IntentFilter(BluetoothDevice.ActionBondStateChanged);
            _activity.ApplicationContext.RegisterReceiver(_receiver, filter);

            filter = new IntentFilter(BluetoothDevice.ActionPairingRequest);
            _activity.ApplicationContext.RegisterReceiver(_receiver, filter);
        }