BluetoothAdapter mBluetoothAdapter = BluetoothAdapter.getDefaultAdapter();
Enable bluetooth:
if (!mBluetoothAdapter.isEnabled()) {
Intent enableBtIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
startActivityForResult(enableBtIntent, REQUEST_ENABLE_BT);
}
<uses-permission android:name="android.permission.BLUETOOTH" />
if (!mBluetoothAdapter.isEnabled()) {
mBluetoothAdapter.enable();
} else {
mBluetoothAdapter.disable();
}
------------------------------------------------------------------------------------------
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN"/>
沒有留言:
張貼留言