0

I'm developing an android app fully based on user location, so I would like to receive the coordinates as frequently as possible. For this case I decided to create a service that will run in the background (looping) and use user GPS and NETWORK providers every 10-15 seconds and after it received a fix, turn them off. Is it a good practice?

Kunj Mehta
  • 411
  • 4
  • 11
SET1
  • 29
  • 4
  • You can use geofencing to check if the user is moving or not. If the user is not moving, you could stop the service and reset it once you detect movement again (aka the user stepped over the geofence). – Luís Henriques Jul 13 '18 at 16:34
  • @LuísHenriques I don't think that geofences is what I need. The problem here is that NETWORK provider is not accurate. – SET1 Jul 13 '18 at 16:43
  • Yeah, it is not. GPS has way more accuracy. If you're not indoors, why not use GPS? But if you are indoors, I think Google has a position API that is extremely accurate. This project uses it (I think that's the correct one): https://github.com/Phantast/smartnavi – Luís Henriques Jul 13 '18 at 16:58

1 Answers1

1

When you are convinced that you need user accurate location and you need it to be update then you need it. However you can take a look at this answer to understand preferred manner to implement it (of course with a little change)

And please consider using Google Fused Location :

The Google Location Services API, part of Google Play Services, provides a more powerful, high-level framework that automatically handles location providers, user movement, and location accuracy. It also handles location update scheduling based on power consumption parameters you provide. In most cases, you’ll get better battery performance, as well as more appropriate accuracy, by using the Location Services API.

Refrence

alizeyn
  • 2,300
  • 1
  • 20
  • 30
  • Thanks. I'm afraid that my users will not understand why their GPS is getting in use every few seconds (they will see GPS icon flickering in the status bar because of the loop in my service). Because of this they might want to delete the app. Thats a big problem for me right now. But, it's also the best solution for my case. – SET1 Jul 13 '18 at 18:55