Android Bluetooth 配对

android 配对与取消配对的方法:

private void pairDevice(BluetoothDevice device) {

try {

    if (D)

    Log.d(TAG, "Start Pairing...");



    waitingForBonding = true;



    Method m = device.getClass()

        .getMethod("createBond", (Class[]) null);

    m.invoke(device, (Object[]) null);



    if (D)

    Log.d(TAG, "Pairing finished.");

} catch (Exception e) {

    Log.e(TAG, e.getMessage());

}

}



private void unpairDevice(BluetoothDevice device) {

try {

    Method m = device.getClass()

        .getMethod("removeBond", (Class[]) null);

    m.invoke(device, (Object[]) null);

} catch (Exception e) {

    Log.e(TAG, e.getMessage());

}

}

 

你可能感兴趣的:(BlueTooth)