Example usage for android.bluetooth BluetoothGatt requestConnectionPriority

List of usage examples for android.bluetooth BluetoothGatt requestConnectionPriority

Introduction

In this page you can find the example usage for android.bluetooth BluetoothGatt requestConnectionPriority.

Prototype

public boolean requestConnectionPriority(int connectionPriority) 

Source Link

Document

Request a connection parameter update.

Usage

From source file:org.physical_web.physicalweb.BluetoothSite.java

@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
    if (newState == BluetoothProfile.STATE_CONNECTED && status == gatt.GATT_SUCCESS) {
        Log.i(TAG, "Connected to GATT server");
        mBluetoothGatt = gatt;/*from ww w .ja  v  a2s .  co  m*/
        if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP) {
            gatt.requestConnectionPriority(CONNECTION_PRIORITY_HIGH);
            gatt.requestMtu(505);
        } else {
            gatt.discoverServices();
        }
    } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
        Log.i(TAG, "Disconnected to GATT server");
        // ensure progress dialog is removed and running is set false
        close();
    } else if (status != gatt.GATT_SUCCESS) {
        Log.i(TAG, "Status is " + status);
        close();
    }
}