我刚开始学习Android,并在Android Studio中设置了一个API 21项目来使用Bluetooth LE。
深入研究BluetoothDevice后,发现ConnectGatt()方法有两个不同的签名:
public BluetoothGatt connectGatt(Context context, boolean autoConnect,
BluetoothGattCallback callback)
并且
public BluetoothGatt connectGatt(Context context, boolean autoConnect,
BluetoothGattCallback callback, int transport)
我想使用第二个,但构建失败:
错误:(127、26)错误:BluetoothDevice类中的connectGatt方法不能应用于给定类型;需要:Context、boolean、BluetoothGattCallback,找到:Context、boolean、BluetoothGattCallback、int,原因:实际和形式参数列表长度不同
看来编译器设置与Android Studio中的源代码不匹配。
我该如何解决?