2 qq 20942245 qq_20942245 于 2016.04.13 15:40 提问

Android BLE开发 连接后获取不到服务

private BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
List gattServices = null;
if (newState == BluetoothProfile.STATE_CONNECTED) {
gattServices = gatt.getServices();
prepareData(gattServices);
writeCharacteristicRGB(characteristic, 255, 87, 87, 0);
}
}
};

    gatt.getservices 一直为空 是怎么回事啊?是不是没有连接成功?

2个回答

xyrmgzt
xyrmgzt   2016.10.08 01:56

android
private BluetoothGattCallback mGattCallback = new BluetoothGattCallback() {
@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
List gattServices = null;
if (newState == BluetoothProfile.STATE_CONNECTED) {
gattServices = gatt.getServices();
prepareData(gattServices);
writeCharacteristicRGB(characteristic, 25

Genius3115
Genius3115   2017.05.24 09:25

你getService错了,get哪一个服务你也没说,当然null了

Csdn user default icon
上传中...
上传图片
插入图片
准确详细的回答,更有利于被提问者采纳,从而获得C币。复制、灌水、广告等回答会被删除,是时候展现真正的技术了!