Example #1
0
            public override void OnReceive(Context context, Intent intent)
            {
                String action = intent.Action;

                // When discovery finds a device
                if (BluetoothDevice.ACTION_FOUND.Equals(action))
                {
                    // Get the BluetoothDevice object from the Intent
                    BluetoothDevice device = intent.GetParcelableExtra <BluetoothDevice>(BluetoothDevice.EXTRA_DEVICE);
                    // If it's already paired, skip it, because it's been listed already
                    if (device.GetBondState() != BluetoothDevice.BOND_BONDED)
                    {
                        activity.mNewDevicesArrayAdapter.Add(device.GetName() + "\n" + device.GetAddress());
                    }
                    // When discovery is finished, change the Activity title
                }
                else if (BluetoothAdapter.ACTION_DISCOVERY_FINISHED.Equals(action))
                {
                    activity.SetProgressBarIndeterminateVisibility(false);
                    activity.SetTitle(R.String.select_device);
                    if (activity.mNewDevicesArrayAdapter.GetCount() == 0)
                    {
                        var noDevices = activity.Resources.GetText(R.String.none_found).ToString();
                        activity.mNewDevicesArrayAdapter.Add(noDevices);
                    }
                }
            }