29 August, 2014

ConnectGatt function usage

public BluetoothGatt connectGatt (Context context, boolean autoConnect, BluetoothGattCallback callback)

Afte I tested with different modals, I think the parameter autoConnect is not functional correctly.
I still don't know what's usage is, maybe because my test devices are all Samsung.

Anyway, here is the final solution for connection to any peripherals:

int build = android.os.Build.VERSION.SDK_INT;
        if (build == VERSION_CODES.JELLY_BEAN_MR2) {
            currentBLEGatt = device.connectGatt(weakContext.get(), true, gattCallback);
        } else {
            currentBLEGatt = device.connectGatt(weakContext.get(), false, gattCallback);
        }


2 comments: