在配对后进入范围并自动连接到设备时,是否可以自动连接蓝牙LE设备?

时间:2016-06-06 11:44:45

标签: android bluetooth-lowenergy

我正在尝试将UA-651 bp智能连接到手机。但是当它在范围内时,我无法使用设备自动连接我的应用程序? 我也尝试下面的代码,它不适合我.plz给我解决方案

if (device == null) {
            Log.w(TAG, "Device not found.  Unable to connect.");
            return false;
        }
        // We want to directly connect to the device, so we are setting the
        // autoConnect parameter to false.
        // boolean: Whether to directly connect to the remote device (false) or
        // to automatically connect as soon as the remote device becomes
        // available (true).
        mBluetoothGatt = device.connectGatt(this, true, mGattCallback);
        Log.d(TAG, "Trying to create a new connection.");
        mBluetoothDeviceAddress = address;
        mConnectionState = STATE_CONNECTING;
        return true;
    }

0 个答案:

没有答案