private void Discover() { reciever = new LakesideReceiver(); reciever.ConnectionMade += Reciever_ConnectionMade; IntentFilter filter = new IntentFilter(BluetoothDevice.ActionFound); RegisterReceiver(reciever, filter); //BluetoothAdapter. filter = new IntentFilter(BluetoothAdapter.ActionDiscoveryFinished); RegisterReceiver(reciever, filter); filter = new IntentFilter(BluetoothAdapter.ActionDiscoveryStarted); RegisterReceiver(reciever, filter); if (bluetoothAdapter.IsDiscovering) { bluetoothAdapter.CancelDiscovery(); } bool val = bluetoothAdapter.StartDiscovery(); }
private bool StartBluetooth() { LakesideReceiver reciever = new LakesideReceiver(); //reciever.ConnectionMade += Reciever_ConnectionMade; IntentFilter filter = new IntentFilter(BluetoothAdapter.ActionScanModeChanged); RegisterReceiver(reciever, filter); bluetoothAdapter = BluetoothAdapter.DefaultAdapter; if (bluetoothAdapter == null) { return(false); } if (!bluetoothAdapter.IsEnabled) { Intent enableBtIntent = new Intent(BluetoothAdapter.ActionRequestEnable); StartActivityForResult(enableBtIntent, 123); } return(true); }