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
2
votes
1 answer

Purpose of WakeLock in modern Android?

I'm having a hard time understanding the purpose of WakeLock in modern versions of Android, after the introduction of Doze and Foreground Services. It appears as if WakeLocks are pretty much legacy as this point (although not marked as deprecated),…
2
votes
1 answer

Is there any reason for BATTERY_PROPERTY_CURRENT_NOW to return drastically different values on 2 different devices?

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…
user9027744
2
votes
0 answers

Toggle Fast Charging option using code in Android

I have a Samsung phone with an option to enable/disable Fast Charging (Cable) option. Can I do the same programmatically inside an Android app? I looked inside BatteryManager class documentation but it does not have an option to check whether Fast…
jest
  • 699
  • 2
  • 12
  • 28
2
votes
1 answer

getting BATTERY_CHANGED flg=0x60000010 (has extras) when trying to do something when battery is at a defined level

I am trying to change the text of TextView when the battery is at a defined level, but when that happened I got an error instead, the error is java.lang.RuntimeException: Error receiving broadcast Intent { act=android.intent.action.BATTERY_CHANGED…
Salem Masoud
  • 411
  • 11
  • 32
2
votes
0 answers

Prevent android battery managers from stopping my application service

Huawei, Asus and some manufacturers have system battery manager that prevent services to keep running when related application closed. I realized that when i change my application package name to com.telegram.messenger battery managers (of huawei…
Saeed
  • 572
  • 2
  • 7
  • 19
2
votes
0 answers

Estimated remaining battery time / Charging time left

I was trying to figure out the way to calculate the Estimated remaining battery time of battery and this post did help me to do so but it isn't much accurate as the Android OS shows in: Settings > Battery option. Is there any way to pull out that…
Arslan
  • 51
  • 3
2
votes
1 answer

Why BATTERY_PROPERTY_CHARGE_COUNTER is not working as BATTERY_PROPERTY_CURRENT_NOW?

I can read the value of the instantaneous current with _CURRENT_NOW and get the remaining battery capacity in percentage with _CAPACITY. The problem is that I can't have access to the remaining battery capacity in mAh with the property…
Ilan
  • 729
  • 3
  • 8
  • 17
2
votes
0 answers

How to make android start my application automatically when battery is fully charged?

My question is similar to this one: battery receiver fully charged doesnt work . That question has no answers. Here are the approaches I have thought of so far: Approach 1: Register a BroadcastReceiver in the AndroidManifest.xml for…
2
votes
4 answers

Android Battery Broadcasts

I am trying to make a Battery Alarm Application. I was reading the Android docs and found out that we don't need to register a BroadcastReceiver. We could do something like this- IntentFilter ifilter = new…
ray an
  • 1,132
  • 3
  • 17
  • 42
2
votes
1 answer

How to use the new Android BatteryManager API

I'm using the latest Google phone (Nexus 6 / Android 5.1.1) and I tried to use the new BatteryManager API: getLongProperty(BatteryManager.BATTERY_PROPERTY_ENERGY_COUNTER) but it returned Long.MIN_VALUE, which means the device does not support this…
Xavier
  • 65
  • 1
  • 6
2
votes
1 answer

System hangs when running two different LKMs to get battery statistics every second

I am developing a Linux Kernel Module (LKM) which analyzes my laptop's battery parameters and writes to Kernel log file (/var/log/kern.log) for every given time interval. Using the data from log file, I will be plotting a real time graph. You may…
SriramK89
  • 428
  • 7
  • 17
2
votes
1 answer

Android: How to get Battery level status more accurately?

I want to get android battery info with more accuracy. I've found some code which gives battery level and scale but it isn't helping me out much. int level = intent.getIntExtra(BatteryManager.EXTRA_LEVEL, -1); int scale =…
2
votes
0 answers

How to get battery remaining energy in nanowatt-hours?

How can I get battery remaining energy in nanowatt-hours, average battery current in micro amperes and so on from BatteryManager on android versions lower than 5.0? Because constants like…
Dmitrijs
  • 1,333
  • 1
  • 14
  • 20
2
votes
2 answers

Can you manually fire ACTION_BATTERY_LOW?

I'm relatively new to android programming but I'm told most applications have a receiver that will cut down on battery expensive activities when android fires ACTION_BATTERY_LOW. Android developing page says: public static final String…
2
votes
4 answers

Insert point in a number - Android

I've been creating a Battery Status on Android, but the Temperature and the Voltage doesn't come with the Battery Manager, for Example: I need 28.7ºC, but Battery Manager get 287ºC, in Voltage I need 4.357, but it get 4357, so how do i get this…
1 2
3
8 9