小编Ser*_*uan的帖子

检查Android中是否启用了蓝牙时出错(REQUEST_ENABLE_BT无法解析为变量)

我正在尝试这样做:

    BluetoothAdapter bt = BluetoothAdapter.getDefaultAdapter();
    if (bt == null){
        //Does not support Bluetooth
        status.setText("Your device does not support Bluetooth");
    }else{
        //Magic starts. Let's check if it's enabled
        if (!bt.isEnabled()){
            Intent enableIntent = new Intent(BluetoothAdapter.ACTION_REQUEST_ENABLE);
            startActivityForResult(enableIntent, REQUEST_ENABLE_BT);
        }   
    }
Run Code Online (Sandbox Code Playgroud)

但我得到这个错误:

REQUEST_ENABLE_BT无法解析为变量

我该如何解决?

android bluetooth

47
推荐指数
2
解决办法
4万
查看次数

标签 统计

android ×1

bluetooth ×1