BATTERY_PROPERTY_CURRENT_NOW not working on every device. What are alternatives?

My app uses BatteryManager.BATTERY_PROPERTY_CURRENT_NOW to get the battery current of the device:

BatteryManager batteryManager = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);
int current = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CURRENT_NOW), context);

However, it does not work for example on a Samsung Galaxy Tab A. There it returns just 0.

Other apps show the current even on that device. How do they do it? What are alternatives to my method?

From your question ("returns just 0") please take a look at the documentation on getIntProperty: https://developer.android.com/reference/android/os/BatteryManager#getIntProperty(int)

If the property is not supported or there is any other error, return

(a) 0 if targetSdkVersion < VERSION_CODES.P

or

(b) Integer.MIN_VALUE if targetSdkVersion >= VERSION_CODES.P.

stackoverflow, BATTERY_PROPERTY_CURRENT_NOW not working on every device. What are alternatives? to get the battery current of the device: It seems to be working. I will not miss the Windows 10 driver update at all. It is a beautiful feature that works horribly with lots of computers, I've seen it broke at least 10 different systems from friends and family. Two days have passed and windows 10 has not updated the driver again.

Use this method:

int getBatteryPercent(Context context) {
    Intent intent = context.registerReceiver(null, new IntentFilter(Intent.ACTION_BATTERY_CHANGED));
    if (intent != null) {
        int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1);
        int scale = intent.getIntExtra(BatteryManager.EXTRA_SCALE, -1);
        return level * 100 / scale;
    }
    return 0;
}

java, BATTERY_PROPERTY_CURRENT_NOW not working on every device. What are alternatives? 发表于2019-9-23 | | 暂无分类. My app uses BatteryManager. But don’t worry, there are plenty of alternatives to keep your device in a working state even when your Android phone’s power button is not working. Not every method works for all devices.

Try this :

BatteryManager batteryManager = (BatteryManager) context.getSystemService(Context.BATTERY_SERVICE);

    int current = batteryManager.getIntProperty(BatteryManager.EXTRA_LEVEL), context)

[PDF] A Framework for Automated Measurement of Energy Consumption , BATTERY_PROPERTY_CURRENT_NOW not working on every device. What are alternatives?. My app uses BatteryManager. If your overactive bladder medication isn’t working, don’t give up. and each approach has pros and cons. Here are three of the most common alternatives: 1. The device has a long

java, more devices. Therefore, the framework is improved based on this alternative and A user issues a command to measure an application's energy consumption in a device. 2. can be applied in every mobile device and every version of Android system. BATTERY PROPERTY CURRENT Now. Positive� If Adobe Digital Editions isn't working properly. There are a few ways you can try to fix issues with downloading or transferring ebooks using Adobe Digital Editions (ADE): Update to the most recent version of ADE, then try downloading or transferring the ebook again.

Diff, BATTERY PROPERTY CURRENT NOW来获取设备的电池电流: 但是,它在三星Galaxy Tab A上不起作用。它只返回。 BATTERY_PROPERTY_CURRENT_NOW not working on every device. What are alternatives? An anonymous Slashdot reader is asking whether or not there are any alternatives to Android or iOS smartphones: Like most of us, I've owned a few smartphones over time, ranging from a Nokia E71 to a Samsung Android phone and now, an Apple iPhone.

BatteryManager, Accessories for Android all have one thing in common; they all connect to an Android but not change any API behavior, such releases may not be accompanied by a easily and reliably identify the version of Android +running on their devices. +BATTERY_PROPERTY_CURRENT_NOW Instantaneous battery current in� If the charging system stopped working, the battery’s charge would soon be depleted, leaving the car with a “dead battery.” If the battery is weak and the alternator is not working, the engine may not have enough electrical current to fire the spark plugs, so the engine will stop running.

Comments
  • have you tried something like this get-battery-level-and-state-in-android
  • Possible duplicate of Getting the battery current values for the Android Phone.
  • So, it is just not supported on some devices… That explains it at least.
  • where's the difference, beside the introduced syntax errors?