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
1
vote
1 answer

How to detect remaining battery power through android programming?

I am working on battery saver app. There I need to detect remaining battery. I have done following. public class HomeActivity extends Activity { TextView tv_battery; @Override public void onCreate(Bundle b) { super.onCreate(b); …
D-JOhn
  • 23
  • 5
1
vote
2 answers

In Android, is there a way to reduce battery drain while using GPS?

In our app, we are taking latitude and longitude every 5 seconds from the GPS to improve the location accuracy. In our app, we have to draw a line as per the user's movement. But we are facing the battery drain problem. Is there any way to reduce…
1
vote
0 answers

Make a "Device's Temperature Live Graph"

I'm making a Device's Temperature Live Graph. But the temperature in the graph is always 0 (I do have BATTERY_STATS permission). private final Handler mHandler = new Handler(); private Runnable mTimer1; private Runnable mTimer2; private…
1
vote
0 answers

BATTERY_PROPERTY returns 0

I'm making a app based on BatteryManager. But every BATTERY_PROPERTY returns 0. Here's my code: if(Build.VERSION.SDK_INT >=21){ BatteryManager bm = (BatteryManager) MainActivity.this.getSystemService(Context.BATTERY_SERVICE); int…
Chris Maverick
  • 928
  • 1
  • 8
  • 18
1
vote
2 answers

Android Power consumption of a method

For a research project I need to measure the power consumption of some functionality. So I would like to measure the power consumption of a method. For example: method computeSomething() needed x microampere-hours. Is this possible? If yes, how? I…
dju
  • 129
  • 4
  • 18
1
vote
2 answers

What is the difference between BATTERY_STATUS_CHARGING and BATTERY_PLUGGED_AC?

I am learning about broadcast receiver, and following the official docs What is the difference between BatteryManager.BATTERY_STATUS_CHARGING and BatteryManager.BATTERY_PLUGGED_AC I use telnet localhost 5554 and type power ac off then power ac on. I…
Lai
  • 115
  • 1
  • 6
1
vote
0 answers

Android BatteryManager.BATTERY_PLUGGED_AC not working

I have a broadcastreceiver that receives the event android.intent.action.ACTION_POWER_CONNECTED correctly. Then I use this code to detect if the device has been connected to the wall socket (AC), to a USB or to a Wireless charging: IntentFilter…
Ton
  • 9,235
  • 15
  • 59
  • 103
1
vote
3 answers

Broadcast receiver for Battery isn't working

I'm trying to use a BroadcastReceiver for the battery state, and do something when its level is below 20% and it's not charging. The problem is that it just doesn't work when the battery goes 20%. Here's the code, I hope somebody can help me: public…
1
vote
1 answer

How to check battery capacity Android Wear (API level 20)

I would like to readout the battery capacity left from my Moto 360. I've come along watch faces that show this value, but I was wondering how to get it. I would like to display this value on my own watch face i'm creating. From API level 21 it is…
patrick
  • 1,282
  • 4
  • 21
  • 37
1
vote
2 answers

Current Battery State always returning "Charging" in ios

I am getting battery state as UIDeviceBatteryStateCharging even though my iPhone battery is 100% charged. It should give me state as UIDeviceBatteryStateFull. My code is as follows. [[UIDevice currentDevice]setBatteryMonitoringEnabled:YES]; int…
Rakesh
  • 1,177
  • 1
  • 15
  • 31
0
votes
1 answer

How to Calculate Android Device Battery Capacity?

Currently, I am working on an Android project for which I need to get the device's Battery Capacity. This function retrieves battery percentage and remaining battery current from BatteryManager and then calculates Maximum capacity (mAh). But I need…
Ayan Roy
  • 1
  • 1
0
votes
0 answers

In Android, Battery Manager, PLUGGED_USB is not working

IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); final Intent batteryStatus = registerReceiver(null, ifilter); // Are we charging / charged? int status =…
Garima
  • 1
  • 3
0
votes
1 answer

How to know programmatically if 'Put unused apps to sleep" is enabled on Samsung devices

I have an alarm clock app. In case the users have a Samsung device I explain to them how the "Put unused apps to sleep" feature might affect the performance of the clock and refer them to the battery manager to disable it using the next code: …
Simple UX Apps
  • 611
  • 2
  • 10
  • 20
0
votes
1 answer

how to solve inferred type is String but Int was expected in Kotlin method?

I'm using the BATTERY_SERVICE on Android studio and I want to get the changes on the battery levels using this code: val bm = applicationContext.getSystemService(BATTERY_SERVICE) as BatteryManager // Get battery change val level: Int =…
0
votes
0 answers

Same BATTERY_PROPERTY_CHARGE_COUNTER values on different Samsung devices

I am working on an app that uses BatteryManager to get different battery information. I have seen that in some different Samsung devices (S20 Ultra, S21 Ultra, S22 Ultra) I am getting the same value returned from BATTERY_PROPERTY_CHARGE_COUNTER…
PayToPwn
  • 1,238
  • 1
  • 16
  • 29
1 2 3
8 9