Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try this code:</p> <pre><code>private final BroadcastReceiver mBluetoothPickerReceiver = new BluetoothConnectActivityReceiver(this); void connectToService(String defaultAdapter) { if (defaultAdapter == null) { registerReceiver(mBluetoothPickerReceiver, new IntentFilter(BluetoothDevicePicker.ACTION_DEVICE_SELECTED)); startActivity(new Intent(BluetoothDevicePicker.ACTION_LAUNCH) .putExtra(BluetoothDevicePicker.EXTRA_NEED_AUTH, false) .putExtra(BluetoothDevicePicker.EXTRA_FILTER_TYPE, BluetoothDevicePicker.FILTER_TYPE_ALL) .setFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)); } else { mCardroid.getCardroidService().connectTo(defaultAdapter); } } public class BluetoothConnectActivityReceiver extends BroadcastReceiver { private BluetoothConnectActivity bluetoothConnectActivity; public BluetoothConnectActivityReceiver(BluetoothConnectActivity bluetoothConnectActivity) { this.bluetoothConnectActivity = bluetoothConnectActivity; } @Override public void onReceive(Context context, Intent intent) { if(BluetoothDevicePicker.ACTION_DEVICE_SELECTED.equals(intent.getAction())) { context.unregisterReceiver(this); BluetoothDevice device = (BluetoothDevice) intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE); bluetoothConnectActivity.connectToService(device.getAddress()); } } } </code></pre> <p>The reference of complete code is :</p> <p><a href="http://code.google.com/p/carbot/source/browse/trunk/src/net/cardroid/?r=8" rel="nofollow">http://code.google.com/p/carbot/source/browse/trunk/src/net/cardroid/?r=8</a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload