When you wake up every five minutes,. don't requestSingleUpdate but do regular updates and wait until you get a different location.
On Monday, June 11, 2012 4:24:39 AM UTC-4, dherrero wrote: > > Hi > This issue has been discussed many times here and in others sites but I > havent found a solution. > I ve a backgroud service detecting location changes using the > provider NETWORK_PROVIDER. > If a set the parameters minDistance and minTime to zero then I get changes > each few seconds althought many time times the position is the same. This > way will drain the battery. > If a set other values, lets say, distance to 10 meters and time o 60000 it > works when the screen is on. But when the screen is OFF the application > doesnt receive updates until the user wakes up the device. > So I ve added and alarm to wake the device each 5 minutes and > requestSingleUpdate to refresh the location and I use a partial_wake_lock > to ensure the callback is called before the device go to sleep but the > position is always the same even if a am driving. The only solution is to > use this flags before requesting the new position > PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP. In > this way the service receive the correct location but the user wont accept > a program that transform his device in a lantern. I ve tried to turn off > the screen when the new location is received using the hidden api to > Power.setScreenState but I dont like it. > > So......is there any official, elegant way to get location updates in a > background service without draining the battery, without playing with the > screen state and without using hidden api? > Thanks > -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

