1
0
mirror of https://github.com/oliexdev/openScale.git synced 2025-08-20 23:41:45 +02:00

Specify transport LE on Android API >= 23

This commit is contained in:
Erik Johansson
2018-04-28 23:47:52 +02:00
parent e81162f773
commit ecec25d719

View File

@@ -27,6 +27,7 @@ import android.bluetooth.BluetoothGattService;
import android.bluetooth.BluetoothProfile;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Handler;
import android.support.v4.content.ContextCompat;
@@ -398,7 +399,13 @@ public abstract class BluetoothCommunication {
btMachineState = BT_MACHINE_STATE.BT_CLEANUP_STATE;
BluetoothDevice device = btAdapter.getRemoteDevice(hwAddress);
bluetoothGatt = device.connectGatt(context, false, gattCallback);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
bluetoothGatt = device.connectGatt(
context, false, gattCallback, BluetoothDevice.TRANSPORT_LE);
}
else {
bluetoothGatt = device.connectGatt(context, false, gattCallback);
}
}
/**