In my app I am going to use the GPS for getting direction when I am trying to use GPS system. on that time my mobile % of charger will reduce immediately, if there is any idea for overcome from in this issue.
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
Related
I need to keep rough track of a users position, but not really in real time. It's sufficient to handle the location updates when the app is started. However, I still need to know where the user was when the app wasn't running.
Is there a way to get the location history in an app?
I don't really want to have a service just polling last known location all the time since that would be a waste of battery power.
However, I still need to know where the user was when the app wasn't running.
That is not possible.
I don't really want to have a service just polling last known location all the time since that would be a waste of battery power.
Then eliminate your requirement for location history. You only get the locations that you request.
Rough Track can mean you get location of the user (lastKnown or Fresh) after every n-hours. Doing this will not require a service, simply a recurring alarm and receiver will do. In the onReceive method of receiver, you can manage a stack of locations in your app.
You will have to reset the alarm though when the device re-boots. I guess this is an add-on, rest should work fine.
you can not get current location without running your app...
the second way is to make background service ..wich you don't wan't to make...
The other way is to run background service using Alarammanager whenever you want after getting location you can stop the service...like you can make call every hour or 2 times per day...
I have to create an app which runs a service in background and continually update the current location on the server or we can say i have to send my current location at some points. The solutions i have think are following. please look at that and give me some idea.
Running an service in background with boot-starter.
Implementation of alarm manager so service can be started automatically if android kills it.
If my current location is in the radius of the 500 from my points than start to update on server.
and other logic which i have think to prevent continues server update.
I have research on it and found it consumes much battery of phone. So please suggest me how can i optimized it.
There are some ways that can keep your Battery work for a long time though you are using GPS Application.
Turn the GPS function off when not in use, then on when you need a
location.
There are some more ways that you can keep track that GPS doesn't drain much Battery, just read this BLog to get some more idea about it.
I'm looking for the best way to continually monitor the location of an Android device, while using the lowest amount of battery power. My project is basically a phone tracking service, with phone call / sms logging, and location tracking. There is a web interface, which would eventually allow a person to change settings (such as location update interval, so if it was stolen they could track it more effectively), but as standard it should update the location every 30-60 minutes.
I was thinking of using a Service, but would it be better to start a service, request location updates, and then finish? Or some other method?
Cheers
but would it be better to start a service, request location updates, and then finish?
Yes, simply so you do not need to keep a service around all the time. However, it's a bit more complicated than that:
you might never get a fix (e.g., the phone is underground and cannot get GPS signals)
you need to keep the service around until you get a fix or until some timeout occurs
you have to worry about the device falling asleep while all this is going on
I have a LocationPoller component that handles most of that.
I am developing an application which has two GPS services. One of which 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
I would like to write an app on Android to upload my GPS location to an external website once every ~5 minutes. This needs to have as minimal an impact on battery life as possible, but it also needs to work without any user interaction. (Background: I'm competing in an Ironman triathlon which will take me about 14 hours to complete, and want to broadcast my location in near-real-time but without having to worry about fiddling with my phone.)
So my initial thought is to write a Service which uses LocationManager.requestLocationUpdates() with a minTime of 5 minutes, but will this actually wake the device up every 5 minutes for my service to do its job?
It sounds like I would also need to use AlarmManager.setInexactRepeating() to make sure my service is awake while it completes its task but how does that play with requestLocationUpdates()? Should I instead set minTime=0 on requestLocationUpdates() but then go back to sleep as soon as the next update is obtained?
Any general guidance on how to design this is greatly appreciated. I'm a competent Java programmer & will be using Google Maps on the server to plot my location, but am pretty new to Android development so I'm basically looking for a high-level plan on how to architect the client app.
Your service must be alive all the time you want to receive updates.
http://developer.android.com/reference/android/location/LocationManager.html#requestLocationUpdates%28java.lang.String,%20long,%20float,%20android.location.LocationListener%29
You can tell how often you want to be informed of location change with minTime parameter. It does not however decrease battery consumption. GPS is enabled unless you use removeUpdates method no matter how often you want to receive updates.
You can use another approache:enable GPS using method above, read one value, use removeUpdates method, wait 5 minutes and all over again. Delay between enabling and retreiving a location can be between few seconds to few minutes.