Questions tagged [batterymanager]

The BatteryManager class contains strings and constants used for values in the ACTION_BATTERY_CHANGED Intent.

The BatteryManager class contains strings and constants used for values in the ACTION_BATTERY_CHANGED Intent.

130 questions
3
votes
1 answer

How to detect that Android device doesn't have built-in battery?

Some of my users have head unit devices on Android (in their cars) and of course such device doesn't have battery and the next code returns 0 val batteryLevel = batteryManager.getIntProperty(BatteryManager.BATTERY_PROPERTY_CAPACITY) and the next…
user924
  • 8,146
  • 7
  • 57
  • 139
3
votes
0 answers

Bluetooth Battery Level API getBatteryLevel() is not working in Android 8.1.0

I am trying to get the Battery Level from BluetoothDevice in Android 8.1.0 of remotely connected BT device. BluetoothDevice mBTDevice = (BluetoothDevice) bundle .getParcelable(BluetoothDevice.EXTRA_DEVICE); int val =…
Subrat
  • 3,928
  • 6
  • 39
  • 48
3
votes
1 answer

Android :How to get Battery status without Broadcast Receiver for API level 17 and above?

I want to get Battery status. I searched it on stack and i found the sample code using Broadcast Receiver but problem is that in my code i cannot use Broadcast Receiver. So is there any way to get battery status without using Broadcast Receiver. It…
Mayur Kharche
  • 717
  • 1
  • 8
  • 27
3
votes
1 answer

Estimate remaining battery time in android

I am trying to estimate the approx. remaining battery time in Android using below method, but it is not accurate in all the times. Please provide any suggestion to improve the accuracy, Below method will save current time stamp in preference when…
Karthi Ponnusamy
  • 2,031
  • 2
  • 25
  • 41
3
votes
0 answers

Replicate battery Charging/Discharging Unit Test in Android Studio

I am developing an Android app in which I have certain broadcast receiver that will will be broadcasting whenever the state of device is changed from discharging to charging and charging to discharging. I have tested this functionality on the device…
onkar
  • 4,427
  • 10
  • 52
  • 89
3
votes
1 answer

How to get percentage of battery usage by each app in android programatically

I am making a demo for battery usage percentage by all apps.I am able to get the total available battery percentage but want to get battery usage by percentage by each app separate.So Is there any way to do so as lot many apps are available in…
sulphuric Acid
  • 585
  • 6
  • 23
3
votes
0 answers

How to keep screen off when plugging in charger

I noticed that when ever we connect our android device to the charger then the Screen wake up. So my Question is Is it possible to make an app that restrict the enabling of the screen every time we connect our device to the charger. I tried this…
Ritesh
  • 876
  • 9
  • 14
3
votes
2 answers

How frequently are ACTION_BATTERY_CHANGEDs sent, in real devices?

In the emulator, if I set power capacity to a value different from the current value, my BroadcastReceiver's onReceive is called with the new value. (I've registered with ACTION_BATTERY_CHANGED.) In a real device, whose battery is discharging from…
fadedbee
  • 42,671
  • 44
  • 178
  • 308
3
votes
1 answer

Units of android EXTRA_SCALE and LEVEL in battery manager

At the beginning I thought that EXTRA_LEVEL would return a percentage but I've seen in the API that to get the percentage I have to do EXTRA_LEVEL / EXTRA_SCALE So now, I wonder, in which units are those pararameters? Are they mA? Thanks!
Spirrow
  • 1,120
  • 6
  • 18
3
votes
3 answers

Execute a piece of code on certain Battery Level in Android

I'm looking for a way of executing a piece of code within my Android application when the phone reaches 10% battery life. Would anyone be able to point me in the right direction of how to do so?
Paul Alexander
  • 2,686
  • 4
  • 33
  • 69
3
votes
1 answer

Calling PowerStatus.BatteryChargeStatus.ToString() sometimes returns 0

So my method is as follows: PowerStatus powerStatus = SystemInformation.PowerStatus; if (powerStatus.BatteryChargeStatus != BatteryChargeStatus.NoSystemBattery) { var batteryStatus = powerStatus.BatteryChargeStatus.ToString() } From my test…
JKennedy
  • 18,150
  • 17
  • 114
  • 198
3
votes
2 answers

How can I set up an alert that appears at all times?

Right now, I just want some sort of indication of battery status when the user access the apps. For example, if the device is plugged in, then the device should say charging and the level it's at. If the device is unplugged, nothing should be…
Kala J
  • 2,040
  • 4
  • 45
  • 85
3
votes
1 answer

Does anyone know whether the Android addProximityAlert on the LocationManager is battery intensive

I just basically want to add about 20 and sometimes 80 Proximity Alerts with no time expiration with a radius of around 500 meters. Just wondering whether by doing this will suck up the battery real quick? also would it make any difference by…
Chiwai Chan
  • 4,716
  • 4
  • 30
  • 33
2
votes
1 answer

BroadcastReceiver BATTERY_LOW crashed when low battery warninng shown

I have Battery BroadcastReceiver by intent filters BATTERY_LOW and BATTERY_OKAY, this receiver work correctly but when low battery warning shown (battery percent below 15 percent), the application crashed by this log: 12-18 03:13:49.651 1802-1802/…
Morteza Jalambadani
  • 2,190
  • 6
  • 21
  • 35
2
votes
1 answer

How to call computeChargeTimeRemaining , Android BatteryManager?

What is the proper way to call computeChargeTimeRemaining ? The method doesn't exist when I try: BatteryManager mBatteryManager = (BatteryManager)context.getSystemService(Context.BATTERY_SERVICE); long time =…
1
2
3
8 9