Friday, February 14, 2014

Automatic Bluetooth pairing


Bluetooth is now doing about the problem of automatic matching, found himself a following method, but can not be used, heroes know how to do it?

Automatic Bluetooth pairing code modifications

First, write a







Then your
public class PairingRequest extends BroadcastReceiver {
@ Override
public void onReceive (Context context, Intent intent) {
if (intent.getAction (). equals ("ACTION_PAIRING_REQUEST")) {
BluetoothDevice device = intent.getParcelableExtra (BluetoothDevice.EXTRA_DEVICE);
byte [] pinBytes = BluetoothDevice.convertPinToBytes ("1234");
device.setPin (pinBytes);
}
}
}


Bluetooth BluetoothDevice under which the source code in this class to use replacementHere, the radio receivers did not play a role, you have any good way to do
?
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
http://blog.csdn.net/yuejingjiahong/article/details/6630250
Recommended lz read this article. Perhaps there is help, huh
Reply:
You get BluetoothDevice reflection of createBond () method to perform pairing, then you can accept this broadcast
Reply:
Why direct call BluetoothDevice of createBond () method and the method can not be received after this broadcast can be obtained by reflecting it? ?
Reply:
This reflective approach to how to use ah. . Can express about it, thank you. .

No comments:

Post a Comment