相关疑难解决方法(0)

连接到BLE设备后如何获得电池电量?

我正在开发一个应用程序,我必须连接到Android 4.3上的蓝牙设备.

我想通过使用Battery_ServiceBattery_Level获得电池电量.

public class BluetoothLeService extends Service {

    private static final UUID Battery_Service_UUID =
                UUID.fromString("0000180F-0000-1000-8000-00805f9b34fb");

    private static final UUID Battery_Level_UUID =
                UUID.fromString("00002a19-0000-1000-8000-00805f9b34fb");


    public void getbattery() {

        BluetoothGattService batteryService = mBluetoothGatt.getService(Battery_Service_UUID);
        if(batteryService == null) {
            Log.d(TAG, "Battery service not found!");
            return;
        }

        BluetoothGattCharacteristic batteryLevel = batteryService.getCharacteristic(Battery_Level_UUID);
        if(batteryLevel == null) {
            Log.d(TAG, "Battery level not found!");
            return;
        }

         mBluetoothGatt.readCharacteristic(batteryLevel);
    ?????// What should I do that I can get the battery level ??
         Log.d(TAG, "Battery level " + …
Run Code Online (Sandbox Code Playgroud)

android battery bluetooth-lowenergy batterylevel android-4.3-jelly-bean

11
推荐指数
1
解决办法
2万
查看次数

如何在Android中获取蓝牙耳机电池状态

有没有办法在Android中获得蓝牙耳机的电池百分比?

请帮帮我.

提前致谢.

android bluetooth

0
推荐指数
1
解决办法
2万
查看次数