Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: programmatically get battery serial number

Tags:

android

Is it possible to programmatically retrieve the battery serial number on Android ?

I had a look at system properties, but I can't find anything related to battery there.

like image 686
ben75 Avatar asked Sep 11 '25 18:09

ben75


1 Answers

As Android runs on Linux you might get this information from the /proc and/or /sys directories. For example on some devices you can get the serial number by calling

cat /sys/class/power_supply/battery/serial_number

As this is device-dependent it might work or not work for your device. As you can see from this code the actual location of the battery information is usually different on each system, so this approach will only work if you know the location of this data on each of the device you want to support

Also note that accessing this information from user apps might be blocked in more recent Android versions, and you'll need a rooted phone to get it

like image 198
SztupY Avatar answered Sep 13 '25 07:09

SztupY