/* 取得默认的蓝牙适配器 */
private BluetoothAdapter mBtAdapter = BluetoothAdapter.getDefaultAdapter();
//如果蓝牙未打开,打开蓝牙
if (!mBtAdapter.isEnabled()) {
Intent enableIntent = new Intent(
BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, 3);
}
//关闭蓝牙
mBtAdapter.disable();
private BluetoothAdapter mBtAdapter = BluetoothAdapter.getDefaultAdapter();
//如果蓝牙未打开,打开蓝牙
if (!mBtAdapter.isEnabled()) {
Intent enableIntent = new Intent(
BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableIntent, 3);
}
//关闭蓝牙
mBtAdapter.disable();