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.
Related
We are working on an app monitoring service to check how much an app consumes battery, just like what is seen in the devices battery settings page, after some research I found BatteryManager class and ApplicationErrorReport.BatteryInfo class but neither helped reaching the goal.
We don't intend to show the data to the user, just collect it for analysis purposes.
How to obtain such functionality?
I'm using Awareness API for my project and receiving actions via BroadcastReceiver. This is the question with my code: link. The problem is that everything works fine in all android version except in Xiaomi devices. Where BroadcastReceiver not receiving anything after couple of hours. I have tried many solution for this (such as this and this and turning battery saving off for my app), but nothing seems to work.
Google Awareness:
And whilst doing so, the API collates data from multiple sources to
ensure that the data provided is both accurate and of a high quality.
It also takes into account both the power and memory consumption when
accessing these signals - helping to ensure that the battery life and
memory usage of our applications do not have a detrimental effect on
the users device.
As this paragraph says:
It also takes into account both the power and memory consumption when
accessing these signals
and you say:
The problem is that everything works fine in all android version
except in Xiaomi devices. Where BroadcastReciver not receiving
anything after couple of hours
after couple of hours device may going to save more energy
You are listening for "Fence API" to register for changes in the users current environment it may consumes power and thus you do not receive broadcasts you may need to change the device settings to allow using of sensors such as location GPS and other relevant sensors
I think your problem is about battery optimization.
Android Marshmallow introduced Doze mode as a way of reducing battery consumption while the device is asleep. In your specific circumstance, though, you should disable it for your app.
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.
I have 2 android applications A and B, and both of them are reading gps values based on different parameters. Considering both the apps are running on the device, which of the folllowing approaches would be better?
Both A and B are to be different apps, each one with a component to read from GPS.
To develop a third application with a remote service component to transmit GPS data to both A and B
Would battery usage be minimized by going for the second approach or will the GPS component read once and serve all processes, as in the OS?
Please help
There is a very good explanation given in the Android Developers Website about Location Strategies. I would suggest you to take a look at the code examples on the page.
In both of your approaches i believe second approach is quite better because Turning on/off GPS is a quite expensive operation in terms of battery usage.
GPS’s battery draining behavior is most noticeable during the initial acquisition of the satellite’s navigation message. Acquiring each satellite takes 12 to 30 seconds, but if the full almanac is needed, this can take up to 12 minutes. During all of this, your phone is unable to enter a deep sleep. A-GPS (Assisted GPS) partially solves this, by sending the navigational message to your mobile device over your cellular data network or even Wi-Fi. As the bandwidth of either of these greatly dwarves the 50bps of the GPS satellites, the time spent powering the GPS antenna or avoiding deep sleep is greatly reduced.
Referred from this.
I think the most battery-efficient way would be to poll the GPS location with app A normally, and in app B, use LocationRequests and use setPriority() with PRIORITY_NO_POWER. As mentioned in the docs, PRIORITY_NO_POWER will make app B get updates only when another app gets GPS updates (in this case, app A!!). I haven't tried it, but it should work. It definitely saves you the hassle of an extra app :)
Some more info on Google Play Location Services here and here.
is it the same as OS gPS component will run once to serve all
One GPS serves all.
There is no half GPS saving half the power.
But there are other location providers like cell tower and Wifi locationing which uses less power.
But if you need GPS it is absolutley no difference how many apps uses the GPS service.
If GPS is enabled it uses full power.
For the sake of compatibility and function I would suggest having a third process or program which reads and outputs GPS data, as multiple processes polling data from GPS is less efficient.
It would also be faster to have those two apps read the output of a single GPS tracking app and not needing individual components in each app to do so.
For the sake of power the GPS will use the same level of power regardless, though if it's polled more often due to two applications using it then it may use more - though the amount is likely to be minimal unless there are constant requests for location.
Though this may not be the question it would be most power efficient to have the third application poll GPS at specific intervals and the applications may read from its output rather than search location every time.
Second approach seems to be more appropriate but not sure about battery drainage.It depends upon how you implement it.
Also I would suggest try to use passive providers.Refer following link help it works :)
http://fypandroid.wordpress.com/2011/04/11/298/
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.