all.i want to know the phone‘s electricity cost in my apps.but the BatteryManager
can't give the information.how can i get this?
This information is not available via the Android SDK, sorry.
The only way to really know is to hook up a power meter to your hardware to measure the current draw while your app is running. The battery stats in the UI computed from an approximation over time based on the types of things the application is doing.
Related
I've found
several
different
SO
posts
on conserving battery life with Android's
FusedLocationProvider API.
What I'm looking is a way to intelligently select the most location accurate provider, given the state of the host's battery and some knowledge of the power drain of each one (e.g. something like this). In other words, if the battery is nearly dead (for some predetermined value of "nearly"), the service would ideally know to avoid GPS, since that burns a lot of power, and instead use either CellID or WiFi. But I don't see anything in the FusedLocationProvider documentation along these lines.
Is there a way to do something like this with an existing API call, or would I need to roll this myself? Thanks in advance for any pointers.
The screen uses the most power.
if user is on long strech of straight high way you only need to monitor accelerometers and dead rreckon position.
I need to get statistics about the battery in milliAmpere.
I've already found how to get the battery percentage and voltage but not the current.
There are applications like this that can do it but i wonder how.
Thank you
I believe the only way to get the current is via the logcat. The system will occasionally post it to there so you'll need to go back find the last update for it.
There is no way of measuring current drawn from within the system - this or any other app can only estimate it based on timing information and voltage discharge that the system reports. You are not likely to have anything accurate based on just that though - to have more accurate information you need an accurate device power model.
There is a nice article by the Android framework guys about how the power model is built (also applies to the built-in battery power monitor).
TL;DR
Measurement can be accomplished using a bench power supply or using specialized battery-monitoring tools (such as Monsoon Solution Inc.’s Power Monitor and Power Tool software).
Need to control what components of the device are active (screen on/off/brightness level, cellular/wifi/bluetooth radio, gps, CPU, etc.)
Based on those you build an energy profile similar to the example at the bottom of the page
There are also typical values in the table in the document. Warning: these are highly hardware-dependent
You can then apply the model by monitoring the state of the device and activities of applications (screen state, foreground/background, CPU/network use by an app, etc.)
This is a lot of hard work (sorry about that :) ), but there isn't another good way - it is actually an active research problem...
Is there any way to determine what is using power in an app? From what I have found, the most granular I can get is how much power an app itself is using. I want to know what I can do to make my app more efficient in the most empirical way possible as it is easy to justify a change when there are numbers to back it up.
Is there any way to determine what is using power in an app?
You can buy a Qualcomm MDP device and use Trepn to get fairly accurate and detailed power analysis of your app. However, an MDP is expensive.
Otherwise, there is little you can do, simply because current Android production hardware is not instrumented to try to collect this level of information. Even the Battery screen in Settings is mostly just an educated guess.
How to calculate speed without requiring GPS? I have heard of something called "sensor technology" but am not sure what that means. I am asking because I want to make an app, but I don't think it is battery efficient to use GPS, plus it is for a long-term project so I want the app to continuously run without having to manually turn it on or turn on GPS.
GPS is by far the most accurate way to do this.
You can get access to the accelerometers, but they are not remotely accurate enough for this type of application.
The only other way I can think of would be to get one of those bluetooth adapters that you plug into your car's diagnostic port, and get the speedometer input from there. Then, you're wasting power on bluetooth as well.
Just buy a power adapter for your phone to run on the vehicle.
I tried to measure the speed using Android's accelerometer sensor for an indoor-navigation project but that failed miserably. I intented to derive the current speed from the acceleration/deceleration over time and so in the end calculate movements along the X, Y and Z-axis, but that didn't work out at all. The accelerometer sensors of common Android devices are way too inaccurate for that kind of usage.
So, you will have to use GPS. To reduce battery drain, you can increase the intervals (time and/or distance) in which the LocationManager notifies your App. See the minTime and minDistance parameters of it's requestLocationUpdates() method.
Android allows you to use cellular phone antennas and wi-fi access point antennas as reference points to determine your current location without using the GPS (see: locationManager.NETWORK_PROVIDER).
Once determined your position in two different moments/points you can easily calculate your speed in your code.
I don't think one can calculate speed without the assistance of GPS. Speed depends on distance and time. I am not sure if we can calculate distance just like that.
Anyway look at http://developer.android.com/reference/android/hardware/Sensor.html
There we have different sensor types. Perhaps you can make use of one of those.
I think what you are referring to would be considered "dead reckoning" (http://en.wikipedia.org/wiki/Dead_reckoning) and is possible, but will lead to drift and incorrect speed information, especially if the user of your app doesn't have the device mounted securely to whatever is moving.
Would it be a valid use case for your app to go to sleep and turn off the GPS? You might be able to devise a way to turn the GPS back on when you bring the app out of suspension. If you need the location always, then GPS is your best bet. People understand that GPS based apps require power and will come up with a way to plug it in to use it long term.
Perhaps you should think about the use cases for your app and ask if people are willing to drain their battery power for whatever functionality you will offer.
Using acceleration and time you can calculate change in velocity but you don't necessarily know the starting velocity. Plus the accelerometer in an iPhone probably isn't accurate enough for this anyway, but it's not a bad shout.
I need to perform power measurements for android applications. I tried "powertutor" and it gives the power consumption per every application. Yet, I don't know how accurate its readings are. Does anyone know how accurate it is?
Also, I have used the DDMS to profile the android application. I obtain the processes as memory info about it. Is there a way that i can know the power consumption per process in Android? (some rough estimation?) or is it impossible?
I really need to perform "power" profiling for android applications but I don't know how.
In my academic research for measuring power consumption on Android, we use a power supply hooked up to the phone's battery terminals that outputs the voltage and current to a PC. Measure without the app to get a baseline and then compare against measurements with the app running. It's not extremely accurate, but it's the best way we know how.