Is there a way I can make a system call to get the actual battery voltage in Android? I wish do to something like this:
double voltage = getVoltage();
//run code
double newVoltage = getVoltage();
Thanks
EDIT - Working code:
fun getVoltage(context: Context): Int {
val intent = context.registerReceiver(null, IntentFilter(Intent.ACTION_BATTERY_CHANGED))
return intent?.getIntExtra(android.os.BatteryManager.EXTRA_VOLTAGE, -1) ?: -1
}