Android 打开和关闭蓝牙
如何直接打开和关闭蓝牙,而无需弹出询问用户同意的窗口。Android 打开和关闭蓝牙,android,bluetooth,Android,Bluetooth,如何直接打开和关闭蓝牙,而无需弹出询问用户同意的窗口。 我尝试了btAdapter.enable(),但这对我不起作用 据我所知,您需要将其添加到权限xml(AndroidManifest.xml)文件中,以避免用户干预 现在打开或关闭您的愿望:)它需要android.permission.BLUETOOTH\u管理员权限您是否为清单文件添加了权限。{}谢谢我弄明白了,它需要android.permission.BLUETOOTH_管理员权限谢谢我弄明白了,它需要android.permiss
我尝试了btAdapter.enable(),但这对我不起作用 据我所知,您需要将其添加到权限xml(AndroidManifest.xml)文件中,以避免用户干预
现在打开或关闭您的愿望:)它需要android.permission.BLUETOOTH\u管理员权限您是否为清单文件添加了权限。{}谢谢我弄明白了,它需要android.permission.BLUETOOTH_管理员权限谢谢我弄明白了,它需要android.permission.BLUETOOTH_管理员权限谢谢我弄明白了,它需要android.permission.BLUETOOTH_管理员权限谢谢我弄明白了,它需要android.permission.BLUETOOTH_管理员权限
if (!mBluetoothAdapter.isEnabled()) {
//do some thing here
}else{
//do some thing here
}
String status;
if (bluetooth.isEnabled()) {
String mydeviceaddress = bluetooth.getAddress();
String mydevicename = bluetooth.getName();
status = mydevicename + ” : ” + mydeviceaddress;
}
else
{
status = “Bluetooth is not Enabled.”;
}
Toast.makeText(this, status, Toast.LENGTH_LONG).show();