I am testing out the BATTERY_PROPERTY_CURRENT_NOW
function on two different devices.
Firstly I have a Samsung Galaxy S7 (Android 7.0 API 24) and a Nexus 6P (Android 8.1 API 27).
When I run BATTERY_PROPERTY_CURRENT_NOW
on the Samsung I will get a result around -300, which seems about right to me. However on the Nexus I am getting anything from -120000 to 400000. Why would this be so off?
Here is the full code:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
final BatteryManager bm = (BatteryManager) getApplicationContext().getSystemService(Context.BATTERY_SERVICE);
int current = bm.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW);
TextView textView = findViewById(R.id.textView);
textView.setText(String.valueOf(current));
}
I'm not sure if it's because the Nexus is a more recent version of Android? But any suggestions would be welcome.