0

I've searched through a number of the questions and answers in regards to the LocPoller from Commonsware and haven't found the answer to my problem. I have tried using the demo of the latest from github and I'm having issues. First I must admit that I modified the PERIOD in the demo so the alarm fires every 15 seconds. I realize this will be a large drain on the batter and it's just for testing. I would expect that the LocationReceiver's onReceive() would be called ever 15 seconds but that isn't happening.

Debugging things I see that the alarm is triggering and everything seems good in that it's getting to the PollerThread and calling sendBroadcast. So I assume I have something setup wrong, but I'm not sure what. Other than changing the PERIOD in the demo everything else is as is. I've tried running this on a device and emulator (Level 8). Any help in debugging this would be appreciated.

In the end the functionality I'm looking for is to have the ability to keep track of a phones location so at any point my app can get the current location. I saw this in my research and though it fit the bill perfect. If someone has a better idea of different approach I'd love to hear it.

Thanks, Rindress

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
rindress
  • 706
  • 1
  • 6
  • 12

1 Answers1

1

In the end the functionality I'm looking for is to have the ability to keep track of a phones location so at any point my app can get the current location. I saw this in my research and though it fit the bill perfect.

No, it is not.

If someone has a better idea of different approach I'd love to hear it.

Step #1: Call requestLocationUpdates() when you want to start receiving location updates in your app

Step #2: Use the location fixes delivered to your LocationListener, or call getLastKnownLocation(), as needed

Step #3: Call removeUpdates() when you no longer want to receive location updates in your app

CommonsWare
  • 986,068
  • 189
  • 2,389
  • 2,491
  • "which it could be running in the background for a very long time, possibly always" -- your users may not like this very much. "Also this didn't answer my original question which was just about the LocationPollerDemo?" -- 15 seconds is an inappropriate period for `LocationPoller`. The complete and entire point behind `LocationPoller` is to give you *occasional* location updates *when your app is not running*. Hence, `LocationPoller` is not suitable for your scenario. – CommonsWare Jun 01 '12 at 15:33
  • Got it thanks. I appreciate you taking the time to answer, and clarify the response. I totally understand that users will not like this approach, however; I have not found another approach that would still give good location information and be less of a battery drain. Thanks again for the quick responses. – rindress Jun 01 '12 at 15:47