0

I am having a problem with location updates that is kind of hard to articulate.

I am attempting to write an algorithm that creates location updates based on distance from known locations on the map. I need to get these updates even when my application isn't running -- so I am using requestLocationUpdates(PendingIntent). Kind of like proximity alert, only not as aggressive.

What happens is I register for the location update based on the known location I get an update right away -- which forces the application to recalculate the location updates and if needed re-request. So I guess what I am saying is I don't need the immediate location update when I register for updates. Is there anyway to do this? Any other ideas on implementation?

Thanks.

  • how about storing the reference location in a preference??? and when you get the location just use the reference from preference to calculate your distance from it...hope I got the question correctly. – Navin Ilavarasan Jan 26 '12 at 18:50
  • I thought about/tried that. But on reboot that preference is still there. I need it cleared ... or need to be able to tell if it was set before or after last reboot. – Delicious Software Jan 26 '12 at 19:06
  • another possible implementation is to pass the reference Location as an extra to the pending intent or use the BOOT_COMPLETE broadcast to reset the preference(I would prefer adding extras). Please also refer http://stackoverflow.com/questions/4340431/how-can-i-correctly-pass-unique-extras-to-a-pending-intent on how to add extras to pending intent as it has few things to be noted. – Navin Ilavarasan Jan 26 '12 at 19:14
  • Unless I misunderstand you adding the location as an extra would still cause the location notification to fire -- only I would be able to intercept it at the broadcast receiver and choose to ignore it? Is this what you meant? – Delicious Software Jan 26 '12 at 19:21
  • Ok...maybe your question was not so clear/or my understanding capability is very bad....is it that you want location updates to be triggered after a particular time interval??? – Navin Ilavarasan Jan 26 '12 at 19:25
  • Based on your previous response I think you got my question right. Just currently it causes two "location locks" because my application need to know the location to set the location requests. So I request the location requests and I get one instantly -- instead of after the device has traveled the specified distance (which is what I want) – Delicious Software Jan 26 '12 at 19:28
  • use an alarm manager to trigger check for location after whatever time you want.... – Navin Ilavarasan Jan 26 '12 at 19:30
  • I was just sitting here thinking that. If I did an alarm first -- then after that alarm I can just register location events I might be OK. – Delicious Software Jan 26 '12 at 19:32
  • I do not like the alarm idea only because I cannot guarantee travel time. If you are located in CA and the reference is NY it is very different times based on mode of transportation. And what would I do for teleporting becomes affordable and mainstream? – Delicious Software Jan 26 '12 at 19:52
  • if you see even the proximity manager works on alarm...it wakes up,checks for location and then sleeps.(ofcourse the sleeping time varies according to the device state,like if the device is locked the sleep is about 5 minutes...you can probably think of something like that)....and if you are planning for very large areas(between cities)...you can also think of using the cell area to find the location(open Cell Id gives you something like that...and then once you find the broader location(or maybe android location manager also can use Cell id to find locations)...use the GPS for finer locations – Navin Ilavarasan Jan 26 '12 at 20:47
  • Thanks for your comments. I will look into the Cell ID functionality you mention. – Delicious Software Jan 27 '12 at 13:08

0 Answers0