当前位置: 首页>>代码示例>>Java>>正文


Java BluetoothProfile.STATE_DISCONNECTING属性代码示例

本文整理汇总了Java中android.bluetooth.BluetoothProfile.STATE_DISCONNECTING属性的典型用法代码示例。如果您正苦于以下问题:Java BluetoothProfile.STATE_DISCONNECTING属性的具体用法?Java BluetoothProfile.STATE_DISCONNECTING怎么用?Java BluetoothProfile.STATE_DISCONNECTING使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.bluetooth.BluetoothProfile的用法示例。


在下文中一共展示了BluetoothProfile.STATE_DISCONNECTING属性的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: disconnectDevice

public void disconnectDevice(String address) {
    BluetoothGatt bluetoothGatt = addressToGattClient.get(address);
    if (btAdapter == null || address == null || bluetoothGatt == null) {
        // Broadcast the disconnect so BleFlow doesn't hang waiting for it; something else
        // already disconnected us in this case.
        sendGattBroadcast(address, BleEvents.GATT_DISCONNECT, null);
        return;
    }
    BluetoothDevice device = btAdapter.getRemoteDevice(address);
    int bleState = bluetoothManager.getConnectionState(device,
            BluetoothProfile.GATT);
    if (bleState != BluetoothProfile.STATE_DISCONNECTED
            && bleState != BluetoothProfile.STATE_DISCONNECTING) {
        bluetoothGatt.disconnect();
    } else {
        bluetoothGatt.close();
        addressToGattClient.remove(address);
        sendGattBroadcast(address, BleEvents.GATT_DISCONNECT, null);
    }
}
 
开发者ID:google,项目名称:science-journal,代码行数:20,代码来源:MyBleService.java

示例2: getStateDescription

public static String getStateDescription(int state) {
    switch (state) {
        case BluetoothProfile.STATE_CONNECTED:
            return "Connected";
        case BluetoothProfile.STATE_CONNECTING:
            return "Connecting";
        case BluetoothProfile.STATE_DISCONNECTED:
            return "Disconnected";
        case BluetoothProfile.STATE_DISCONNECTING:
            return "Disconnecting";
        default:
            return "Unknown State "+state;
    }
}
 
开发者ID:holgi-s,项目名称:RangeThings,代码行数:14,代码来源:GattProfile.java

示例3: stateToString

/**
 * Converts the connection state to String value
 * @param state the connection state
 * @return state as String
 */
protected String stateToString(final int state) {
	switch (state) {
		case BluetoothProfile.STATE_CONNECTED:
			return "CONNECTED";
		case BluetoothProfile.STATE_CONNECTING:
			return "CONNECTING";
		case BluetoothProfile.STATE_DISCONNECTING:
			return "DISCONNECTING";
		default:
			return "DISCONNECTED";
	}
}
 
开发者ID:runtimeco,项目名称:Android-DFU-App,代码行数:17,代码来源:BleManager.java

示例4: getStateDescription

public static String getStateDescription(int state) {
    switch (state) {
        case BluetoothProfile.STATE_CONNECTED:
            return "Connected";
        case BluetoothProfile.STATE_CONNECTING:
            return "Connecting";
        case BluetoothProfile.STATE_DISCONNECTED:
            return "Disconnected";
        case BluetoothProfile.STATE_DISCONNECTING:
            return "Disconnecting";
        default:
            return "Unknown State " + state;
    }
}
 
开发者ID:thejeshgn,项目名称:BleUARTPeripheral,代码行数:14,代码来源:UARTProfile.java

示例5: onConnectionStateChange

@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
    if (mOnConnectionStateChangeListener != null) {
        mOnConnectionStateChangeListener.onConnectionStateChange(gatt, status, newState);
    }
    String intentAction;
    String tmpAddress = gatt.getDevice().getAddress();
    if (newState == BluetoothProfile.STATE_DISCONNECTED) {
        intentAction = ACTION_GATT_DISCONNECTED;
        Log.i(TAG, "Disconnected from GATT server.");
        broadcastUpdate(intentAction, tmpAddress);
        close(tmpAddress);
    } else if (newState == BluetoothProfile.STATE_CONNECTING) {
        intentAction = ACTION_GATT_CONNECTING;
        Log.i(TAG, "Connecting to GATT server.");
        broadcastUpdate(intentAction, tmpAddress);
    } else if (newState == BluetoothProfile.STATE_CONNECTED) {
        mConnectedAddressList.add(tmpAddress);
        intentAction = ACTION_GATT_CONNECTED;
        broadcastUpdate(intentAction, tmpAddress);
        Log.i(TAG, "Connected to GATT server.");
        // Attempts to discover services after successful connection.
        Log.i(TAG, "Attempting to start service discovery:" +
                mBluetoothGattMap.get(tmpAddress).discoverServices());
    } else if (newState == BluetoothProfile.STATE_DISCONNECTING) {
        mConnectedAddressList.remove(tmpAddress);
        intentAction = ACTION_GATT_DISCONNECTING;
        Log.i(TAG, "Disconnecting from GATT server.");
        broadcastUpdate(intentAction, tmpAddress);
    }
}
 
开发者ID:junkchen,项目名称:BleLib,代码行数:31,代码来源:MultipleBleService.java

示例6: connectionState

private String connectionState(int status) {
    switch (status) {
        case BluetoothProfile.STATE_CONNECTED:
            return "Connected";
        case BluetoothProfile.STATE_DISCONNECTED:
            return "Disconnected";
        case BluetoothProfile.STATE_CONNECTING:
            return "Connecting";
        case BluetoothProfile.STATE_DISCONNECTING:
            return "Disconnecting";
        default:
            return String.valueOf(status);
    }
}
 
开发者ID:ruipoliveira,项目名称:livingCity-Android,代码行数:14,代码来源:MainActivity.java

示例7: stateToString

private String stateToString(int state)
{
    if (state == BluetoothProfile.STATE_CONNECTED)
        return "CONNECTED";
    if (state == BluetoothProfile.STATE_CONNECTING)
        return "CONNECTING";
    if (state == BluetoothProfile.STATE_DISCONNECTED)
        return "DISCONNECTED";
    if (state == BluetoothProfile.STATE_DISCONNECTING)
        return "DISCONNECTING";

    return String.format("Unknown state %d (0x%08X)", state, state);
}
 
开发者ID:NordicID,项目名称:nur_sample_android,代码行数:13,代码来源:UartService.java

示例8: onConnectionStateChange

@Override
public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
    if (mOnConnectionStateChangeListener != null) {
        mOnConnectionStateChangeListener.onConnectionStateChange(gatt, status, newState);
    }
    String intentAction;
    String address = gatt.getDevice().getAddress();
    if (newState == BluetoothProfile.STATE_DISCONNECTED) {
        Log.i(TAG, "onConnectionStateChange: DISCONNECTED: " + getConnectDevices().size());
        intentAction = ACTION_GATT_DISCONNECTED;
        isConnect = false;
        mConnState = STATE_DISCONNECTED;
        Log.i(TAG, "Disconnected from GATT server.");
        broadcastUpdate(intentAction, address);
        close();
    } else if (newState == BluetoothProfile.STATE_CONNECTING) {
        Log.i(TAG, "onConnectionStateChange: CONNECTING: " + getConnectDevices().size());
        isConnect = false;
        intentAction = ACTION_GATT_CONNECTING;
        mConnState = STATE_CONNECTING;
        Log.i(TAG, "Connecting to GATT server.");
        broadcastUpdate(intentAction, address);
    } else if (newState == BluetoothProfile.STATE_CONNECTED) {
        Log.i(TAG, "onConnectionStateChange: CONNECTED: " + getConnectDevices().size());
        intentAction = ACTION_GATT_CONNECTED;
        isConnect = true;
        mConnState = STATE_CONNECTED;
        broadcastUpdate(intentAction, address);
        Log.i(TAG, "Connected to GATT server.");
        // Attempts to discover services after successful connection.
        Log.i(TAG, "Attempting to start service discovery:" +
                mBluetoothGatt.discoverServices());
    } else if (newState == BluetoothProfile.STATE_DISCONNECTING) {
        Log.i(TAG, "onConnectionStateChange: DISCONNECTING: " + getConnectDevices().size());
        isConnect = false;
        intentAction = ACTION_GATT_DISCONNECTING;
        mConnState = STATE_DISCONNECTING;
        Log.i(TAG, "Disconnecting from GATT server.");
        broadcastUpdate(intentAction, address);
    }
}
 
开发者ID:junkchen,项目名称:BleLib,代码行数:41,代码来源:BleService.java


注:本文中的android.bluetooth.BluetoothProfile.STATE_DISCONNECTING属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。