Questions tagged [battery]

A battery is a portable electrical power source which is often used in mobile devices.

An electric battery is a device consisting of one or more electrochemical cells that convert stored chemical energy into electrical energy.

Each cell contains a positive terminal, or cathode, and a negative terminal, or anode. Electrolytes allow ions to move between the electrodes and terminals, which allows current to flow out of the battery to perform work.

871 questions
4
votes
2 answers

which way is better in android , JobScheduler or use timer?

I'm developing a chat application, For getting new messages in real-time we use a foreground service. (because of some situation we can't use FCM) To be confident that clients are connected to the server, We send a ping to server every 1 minute with…
Hosein Kord
  • 187
  • 2
  • 15
4
votes
1 answer

REQUEST_IGNORE_BATTERY_OPTIMIZATIONS Firing but No Prompt

I'm trying to disable battery optimization on Android 9 with ACTION_REQUEST_IGNORE_BATTERY_OPTIMIZATIONS in a push notification when the app is launched. In the activity file (using notification builder): Intent intent = new…
4
votes
0 answers

Detect background battery restriction

Under battery settings for a given app, a user can restrict background battery usage. Is there a way to programmatically determine if the user has turned on this setting for my app? Note: This is not the same as Battery optimization...the feature…
ericwjr
  • 200
  • 2
  • 11
4
votes
0 answers

Android force idle mode vs. really unplug the device

Currently I'm working on an app which does Bluetooth scanning in background service. I realized that the phones behaviour is different if I force the device to sleep mode by adb shell dumpsys battery unplug adb shell dumpsys deviceidle…
Fintasys
  • 1,309
  • 1
  • 9
  • 16
4
votes
0 answers

Difference between Android Battery Optimization and Samsung's Unmonitored Apps

My app was put to deep sleep, just like force killed when Samsung ask to fix the battery drain apps, even my sticky backend service got killed. Looks like there is some way to bring user to the battery optimization feature to disable battery…
Ziwei Zeng
  • 691
  • 5
  • 21
4
votes
1 answer

How to detect that user removed my app from "Not optimized" list in battery optimization?

I have an app that needs to ignore doze mode and it asks the user to add it to not optimized apps list the usual way with: Intent intent = new Intent(); String packageName = getPackageName(); …
Ognyan
  • 13,452
  • 5
  • 64
  • 82
4
votes
2 answers

Socket.IO With Service Draining Battery Dramatically (Android)

Good day. I have a question considering the most best practise for battery managment. Beforehand please do not suggest nor GCM neither Firebase as i am not interested in them and i will tell the reason after. So here is the scenario. I have a…
Volo Apps
  • 235
  • 1
  • 3
  • 12
4
votes
1 answer

Read the current battery charge/discharge rate on a laptop

I've wrote a small piece of code that reads the current battery charge/discharge on my laptop. I followed the example code on this MSDN page. My program updates the information every 100ms (by calling the DeviceIoControl function with…
user472507
  • 75
  • 1
  • 4
4
votes
0 answers

Is there a way to get the detailed battery usage for my app on Android 5.0/5.1/6.0

In Android 6.0, we can the detailed battery usage for each app as shown below. Is there a way to get these numbers programmatically within this app? I tried to use command "dumpsys batterystats --charged MY_APP" and parse the returned values, but…
4
votes
2 answers

How to disable Doze for an app?

The new Doze mode on Android 6 disables nearly every useful background activity. I have an app, which regularly woke up the device (even if no lock screen), kept a partial wake lock, did some scans and reported that to the Internet. It is not a spy…
decades
  • 827
  • 17
  • 25
4
votes
3 answers

Getting iPhone's battery level

I have a simple question. How do I get iPhone's battery level? [UIDevice currentDevice] batteryLevel] Simple enough? However there is a little catch - I can't use UIKit. Here is what I wrote so far, but I don't think it works: // notification…
Kristina
  • 15,859
  • 29
  • 111
  • 181
4
votes
2 answers

Why is my Receiver for charging status always returning false?

I'm trying to detect when a user plugs (or unplugs) in their device to charge. In my receiver, where I determine whether it is plugged in or not, I always get a "false" reading on the status. Here is my code: (In the manifest):
hellaandrew
  • 823
  • 11
  • 23
4
votes
0 answers

Android WiFi Direct Service Discovery and Battery Life

I'm trying to use Wifi P2P NSD to share a small string between phones and "hubs" (servers and clients, respectively) Since phones move around and the hubs will be in fixed places (think beacons), it would be ideal for the phone to constantly…
4
votes
0 answers

How to get battery & mobile-data-usage of specific apps?

Background Starting with some Android version (don't remember which), Android has the ability to show battery stats and mobile-data-usage (3G...) of the installed apps, so that the user will be aware of such a thing and will be able to think if the…
android developer
  • 114,585
  • 152
  • 739
  • 1,270
4
votes
2 answers

Why might my android app occasionally drain battery extremely fast?

Several users of my app have reported their battery draining at around 1% a minute with my app running in the background. I have been unable to replicate this issue even when using the same account credentials on the same device model that the user…
rhnoble
  • 559
  • 4
  • 12