一、首先说明:蓝牙通信必须用手机测试,因为avd里没有相关的硬件,会报错!
好了,看看最后的效果图:
二、概述:
1.判断是否支持Bluetooth
BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
if(bluetoothAdapter == null) {
//the device doesn't support bluetooth
} else {
//the device support bluetooth
}
2.如果支持,打开Bluetooth
if(!bl