Save battery power consumed by gps services in android
I am developing an application which has two GPS services. One of whi开发者_运维百科ch is location tracking which send location updates at every 2 min to server and another service is cyberseatbelt which checks for speed of device when location updates.
With these two services, battery consumption is 77% displayed in my mobile. Without these two services, no battery consumption is displaying.
Is there any solution to save battery power on device while keeping the desired functionality?
You have to tell what you have done to make the battery consumption so high. (Not even clear if battery becomes 77% after 1 minute or 15 minutes or 1 hr).
How are you accessing GPS? Are you running a handler/thread to periodically poll the GPS. If yes, this is wrong approach. You can ask Android to inform you on location changes.
GPS services are usually memory hungry. Do you need GPS services or just looking for location updates? Android comes with a good startup doco for location based services . http://developer.android.com/guide/topics/location/obtaining-user-location.html Try following the steps in this doco to find best user location.
Make sure to stop listening for updates at the appropriate time. Users will not be happy that one app tries to drain the battery even when it is not running.
Try making the app as a background task.. i.e a Service or BroadcastReceiver
精彩评论