Android battery draining rate - android

I'm trying to design an app which changes it's behaviour according to battery draining rate.
That is, there are two states state1 and state2.
it checks for draining rate of each state.
and switches over to the particular state which drains less battery.
so is it possible to check the draining rate of my app (in particular).
ps: both the states use display and network connections.
if yes how can I get the draining rate?
I've noticed in the Battery options of android setting contains per app battery usage can I access these values?

You have two main states (LOW and OKEY). However, I don't think you can access battery usage statistics par apps.
You can read this : http://developer.android.com/training/monitoring-device-state/battery-monitoring.html
IMO, you can do what you want with that.

Related

Activity Recognition Client battery comsumption

I wish to use for my app ActivityRecognitionClient, and I wish it will run always in the background. But how much battery actually it consume and what is the best interval for battery optimization?
In the reference it only says
"Larger values will result in fewer activity detections while improving battery life. Smaller values will result in more frequent activity detections but will consume more power since the device must be woken up more frequently"
Can you tell me in real life how much it will consume per refresh rate?
It is nearly impossible to correctly answer this question because the answer is a resounding "it depends."
The amount of battery power that a particular action will consume on a phone is difficult to determine because there are a ton of different factors that play into it.
First, Android attempts to batch many types of requests such as this together, so if 10 different apps wants to detect updates ever 5 minutes, it will only do it once every 5 minutes instead of 10 times every 5 minutes. Which app and which action is responsible for that?
Second, activity detection relies on whatever sensors (and models of sensors) are available on the device. Different devices have different GPS chips, accelerometer chips, etc. Some devices may not have all of those types of sensors as well. These all change the amount of energy activity recognition will consume.
These are just a few of the reasons it is difficult to determine how much energy an update will consume.
The answer for "how often should I request updates" is "as infrequently as your app can tolerate." Think about your use case and the general statement that more frequent updates will consume more power, and make the appropriate decision from there.

Accelerometer and Gyroscope and its power consumption in Android phones

I'm using accelerometer and gyroscope in my Android app. I want to profile my app for its power consumption. Lets say the app, read these two sensors every 100 millisecond, add all its three axis (x,y,z), and store them in a file.
Now I am not sure if these two sensor are always on or not ? If yes, then most of the power consumption will come from how I use or process these sensors' values in my app. So I have the following questions.
Are these two sensors always on or active ? (If so, any reference).
What does then the register and deregister does ? If they are always on,
then it won't make any difference to deregister them, at least in
terms of power consumption.
Background or reasoning behind these questions:
Gyroscope consumes more power than accelerometer (based on my analysis, its 4-6 times higher). Now if these sensors are always on then I can use them both in my app because my app is not the reason for the power consumption caused by the active status of these sensors. My app will be responsible for the power consumption due to the way I use these sensor values, and how often I read them. However, if these are disabled or off (consuming no power at all), then I have to make a careful decision if I want to use them or not because when I register them, then I am also increasing the power consumption due to their active status in addition to the processing their values.
Mostly as addition to the answer from Andriy Omelchenko with some more links:
1.
This is broadly and "manufacturer independent" documented in Androids Architecture Documentation in the Sensors Section. Specifically that Accelerometer and Gyroscope are handled as non-wakup sensors which report events continuously but may not wake up the SoC.
So yes, you can assume these 2 sensors are always on.
2.
Furthermore the documentation states: If an Application needs the data in background, it needs to hold a Wakelock - probably the Partial Wakelock which will keep the system from going into low power/sleep mode - such that events are processed and delivered without being dropped. Obviously this will drain the battery faster.
You could imply that registering/unregistering may have a low effect on power as long as you don't keep a Wakelock.
But in general you shouldn't assume it is useless to register/deregister sensors for power optimization - except one-shot sensors. Not only because of the power used for processing and delivery of events to apps and the possibility of keeping the system from its sleep. It is a Framework recommendation and these are normally not without cause like the use of register with report delay to make use of batching if possible. The impact may change with different hardware or other factors.
It could also be a funny bug source if - for example - you assume that data is provided depending on the Wakelock: The documentation only states that for non-wake-up sensors the driver is not allowed to hold a Wakelock and the sensor shouldn't wake the SoC. Meaning your app could be processing events in the background or not depending on device, system, installed apps and so on.
From Official site: "Always make sure to disable sensors you don't need, especially when your activity is paused. Failing to do so can drain the battery in just a few hours. Note that the system will not disable sensors automatically when the screen turns off."
"Are these two sensors always on or active?" - seems this question has no general answer because it depends on hardware. Actually accelerometer and gyroscope has low power consumption, but they support by OS may consume more battery.
"What does then the register and deregister does ?" - eliminates power consumption for data processing from them.
The accelerometer and gyroscope are not always on. That would be crazy - absolutely anything that draws power in a mobile device is put into a low power mode where-ever possible (no application is currently requesting it). Hence the need to register / deregister.
There isn't a strict specification to require this from hardware manufacturers, because this is a common sense optimization to increase battery life.

Android - how do sensor readings affect battery life

i have added a feature in my app that uses the proximity and accelerometer sensors (the second is to detect shakes). This is implemented in an always running service (if the user selects it of course). But I fear for the battery usage that my ap will have. I have NOT used any wake locks but i still get readings even when screen is off as i can see in my logs. The question is: what of the following is true?
The two mentioned sensors are activated anyway by android system
the whole time (in which case me collecting the readings as well
does not affect battery life...i guess).
Android system turns these sensors off most of the time (in which
case me keeping them always on through my service affects battery
life)
If (2) is true: Is it possible to implement my own sleep cycle for the sensors or will the whole toggle process make things worse?
Amount of power taken by sensor varies from sensor to sensor, and device to device.
On average, your most power hungry sensors are the GPS, accelerometer and gyroscope. Leaving them On all the time will reduce the battery faster.So you should pause the sensor when the device is where-ever not necessary.
After that, the light sensor and compass are much less battery intensive, but if you use them for long enough even they'll affect battery life.
besides this you can test your app for sometime how much it takes, or you can use getPower () to return the power in mA used by this sensor while in use.
There is no exact method for this actually.If your app have to use the sensor then use it when its needed.
thanks
u can reduce the power consumption by reading the sensor's value at some competitively larger time like 50ms,
i.e. any android cell read the data at 5ms or 10ms depend on brand of cell phone and we can manually reduce that time to 50ms to 70ms.
it would increase the battery life and won't affect on process as well.
thank you

How can i save Battery power using in writing app

In Android 4.4 kit-kat version I saw my writing app is using high battery power ...
in my application I am using Network service to fetch data from server.
so I search the solution to save the battery power .. I found this topic
http://developer.android.com/training/efficient-downloads/efficient-network-access.html#PrefetchData
Any others ways to save the Battery Power Useage and best pratice for reduce battery power using in application.
By taking steps such as disabling background service updates when you lose connectivity, or reducing the rate of such updates when the battery level is low, you can ensure that the impact of your app on battery life is minimized, without compromising the user experience.For more take a look here. Check which part of your app is consuming the thread profiling with trace View. And you also need to aware of your app performance.

Android battery usage

My goal is to decide whether my application has a battery issue or not so I want to add a module that checking the percentage of my app battery usage each interval time.
How can I retrieve the values of the battery usage for each application (or at least my application) by percentage?
I saw several answers in stack overflow saying that there is no way...
Can I do something? even reflection is good for me.
Besides, is there any good dev tool that could help me investigate my app battery consumption? (by components, i.e. wifi, gps, gsm etc.)
thanks
The author of BatteryIndicator wrote in his FAQ-How_does_Battery_Indicator_work?
How does Battery Indicator work? / How does it know what percentage
the battery is at?
The Android system has a mechanism where you can register your app to
be notified when the battery status changes. So Battery Indicator has
a background service that is technically always running but is
essentially always sleeping and using basically no system resources
(because it doesn't do any polling -- it just sleeps and waits to be
notified by the OS when something changes), then when the battery
charge (or plugged-in status) changes, the system wakes it up and
tells it what the new battery charge (and status) is. Then it takes
just a few milliseconds to change its icon to reflect the current
charge (and status) and goes back to sleep.
If you're technically oriented, the documentation for the core API
that Battery Indicator uses is here:
http://developer.android.com/reference/android/os/BatteryManager.html
and the actual source code to the development version of the app is
here: http://code.google.com/p/battery-indicator/source/browse/trunk .
The app shows consumption of different modules
Phone in Standby 59%
Akku in Standby 39%
Display 4%
But i donot know how this is implemented.
How can I retrieve the values of the battery usage for each application (or at least my application) by percentage?
There is nothing in the Android SDK for this, sorry.
Besides, is there any good dev tool that could help me investigate my app battery consumption? (by components, i.e. wifi, gps, gsm etc.)
Buy a Qualcomm MDP and use Trepn. Unfortunately, this is expensive.
Download "Dr. Power" from Android Market.
This app has been developed by a company that has the exact problem.

Categories

Resources