private final BroadcastReceiver mReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
Log.d(TAG, "--onReceive(Context context, Intent intent)--");
String action = intent.getAction();
Log.d(TAG, "Action:" + action);
if (BluetoothDevice.ACTION_BOND_STATE_CHANGED.equals(action)) {
Log.d(TAG, "ACTION_BOND_STATE_CHANGED");
BluetoothDevice device = intent
.getParcelableExtra(BluetoothDevice.EXTRA_DEVICE);
// If it's already paired, skip it, because it's been listed
// already
//Added
boolean a = device.createBond(device.getAddress());
boolean b = device.setPin(device.getAddress(), BluetoothDevice
.convertPinToBytes("0000"));
Log.d(TAG, "createBond:" + a + ", setPin:" + b);
if (a && b) {
Log.d(TAG, "AutoPairing Success !");
//Added_
}
}
}
};