首页 > 解决方案 > 我想知道如何显示服务

问题描述

我目前正在研究一种bluetooth芯片,我想展示它的功能。

我正在尝试该方法getService();,但这个方法返回给我null

private final BluetoothGattCallback mGattCallback =
        new BluetoothGattCallback() {
            @Override
            public void onConnectionStateChange(BluetoothGatt gatt, int status, int newState) {
                String intentAction;
                if (newState == BluetoothProfile.STATE_CONNECTED) {
                    intentAction = ACTION_GATT_CONNECTED;
                    mConnectionState = STATE_CONNECTED;
                    broadcastUpdate(intentAction);
                    Log.i(TAG, "Connected to GATT server.");
                    Log.i(TAG, "Attempting to start service discovery:" +
                            mBluetoothGatt.discoverServices());
                    Log.i(TAG, "Attempting to start service discovery:" +
                            mBluetoothGatt.getService(UUID.fromString(SampleGattAttributes.UUID_Address)));


                } else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
                    intentAction = ACTION_GATT_DISCONNECTED;
                    mConnectionState = STATE_DISCONNECTED;
                    Log.i(TAG, "Disconnected from GATT server.");
                    broadcastUpdate(intentAction);
                }
            }
        };

我想在日志中显示特征列表。预先感谢您的帮助

标签: javaandroidbluetooth

解决方案


推荐阅读