小编Chr*_*n W的帖子

带有传输参数的BluetoothDevice.ConnectGatt()

我刚开始使用Android,并使用蓝牙LE在Android Studio中设置了一个API 21项目.

深入了解BluetoothDevice,向我展示了ConnectGatt()方法的两个签名:

public BluetoothGatt connectGatt(Context context, boolean autoConnect,
                                 BluetoothGattCallback callback)
Run Code Online (Sandbox Code Playgroud)

public BluetoothGatt connectGatt(Context context, boolean autoConnect,
                                 BluetoothGattCallback callback, int transport)
Run Code Online (Sandbox Code Playgroud)

我想使用第二个,但构建失败:

错误:(127,26)错误:类BluetoothDevice中的方法connectGatt不能应用于给定类型; required:上下文,布尔值,找到BluetoothGattCallback:Context,boolean,BluetoothGattCallback,int reason:实际和形式参数列表的长度不同

似乎编译器设置与Android Studio中的源代码不匹配.

我怎样才能解决这个问题?

android bluetooth bluetooth-lowenergy gatt

4
推荐指数
1
解决办法
5474
查看次数

标签 统计

android ×1

bluetooth ×1

bluetooth-lowenergy ×1

gatt ×1