1 year ago

#362061

test-img

Rahul Das

How to get battery percentage or low battery information(to be specific) of the RCU in Android TV

How to get the information about current battery level or low battery level information of the RCU (remote control unit) for my Android TV.

I need to show customised message when the battery level is low i.e., "Time to change the battery....." or similar.

I've seen that the system detects the low battery and shows a system notification, but not sure how can i my application (which is a system application) can get that information.

I've already tried the below approaches, doesn't seems to work

How to get the battery level after connect to the BLE device?

How to get Bluetooth Headset battery level?

and this as well

    val btManager = getSystemService(BLUETOOTH_SERVICE) as BluetoothManager
    val mBluetoothAdapter = btManager.adapter
    val pairedDevices = mBluetoothAdapter.bondedDevices

    val build = StringBuilder()
    for (bt in pairedDevices){
            val method: Method = bt.javaClass.getMethod("getBatteryLevel")
            val value = method.invoke(bt) as Int
            build.append(" (Battery : $value)")
    }
    val tvDetails = findViewById<TextView>(R.id.tv_details);
    tvDetails.text = build.toString()

None of the above method has worked so far, Also i couldn't find anything specific in Official documentation.

Please let me know if anyone know or have found the solution for this. Thanks in advance!

android

bluetooth-lowenergy

android-bluetooth

android-tv

bluetooth-gatt

0 Answers

Your Answer

Accepted video resources