I am developing an application where I want to connect a Bluetooth device main issue is I don\'t want user to enter required pin instead application should do that by himsel
How to set the pin code has been answered above (and that helped me). Yet, I share my simple code below which works with Android 6:
BluetoothAdapter mBTA = BluetoothAdapter.getDefaultAdapter();
if (mBTA.isDiscovering()) mBTA.cancelDiscovery();
mBTA.startDiscovery();
...
/** In a broadcast receiver: */
if (BluetoothDevice.ACTION_FOUND.equals(action)) { // One device found.
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
Log.d(TAG, "Start Pairing... with: " + device.getName());
device.createBond();
}
// If you want to auto-input the pin#:
else if (BluetoothDevice.ACTION_PAIRING_REQUEST.equals(action)){
BluetoothDevice device = intent.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
device.setPin("1234".getBytes());
}