0

I'm trying to get user's gps location when he submit a form (the form result is saved to a file so no need to internet connection), here is what I have tried :

1)Getting location updates (requesting update in 0 second a 0 second interval and 0 m distance) => takes too long (up to 5 minutes), if the user isn't connected to the internet, it will take forever.

2)Getting last known location, if it's not available (null), then try to get location updates => 95% of the times it's a null location (especially when I reinstall the app), and when I try to get the location updates I'm getting the same previous problem.

I can't figure out what I'm supposed to do, any help please? I'm using Google Play Services to get location. I'm open to all solutions.

Also I have noticed that when the connection is enabled it doesn't take too long (I'm using PRIORITY_LOW_POWER), but even in this case I'm not seeing any blinking gps icon on the notification bar, is this normal? (test on android 5.1.1).

Thank you.

hereForLearing
  • 1,209
  • 1
  • 15
  • 33
  • for GPS location you need open sky or you will not get any gps locations updates, connecting to a Internet connection assist your device locate it faster, so its not issue, this is how gps work, go read on gps and how it works – Nishant Pardamwar Jul 13 '17 at 06:04

2 Answers2

0

Have you tried using Fused Location Api provided by Google. This api can help you get location updates fast & easily. Also read Android Location docs for more information

Firoz Memon
  • 4,282
  • 3
  • 22
  • 32
0

Also I have noticed that when the connection is enabled it doesn't take too long (I'm using PRIORITY_LOW_POWER), but even in this case I'm not seeing any blinking gps icon on the notification bar, is this normal? (test on android 5.1.1).

The low power priority means, location api will not make any request for any location provider on your device. And you are not seeing blinking gps icon because low priority will not enable the gps radio. It will wait until other client has requested.

Getting location updates (requesting update in 0 second a 0 second interval and 0 m distance) => takes too long (up to 5 minutes), if the user isn't connected to the internet, it will take forever.

Did you try with PRIORITY_LOW_POWER ? If yes, this is related to my first paragraph.

Getting last known location, if it's not available (null), then try to get location updates => 95% of the times it's a null location (especially when I reinstall the app), and when I try to get the location updates I'm getting the same previous problem.

Again, it's normal to see same result with PRIORITY_LOW_POWER

Possible solution is to one of below

  • PRIORITY_HIGH_ACCURACY

  • PRIORITY_BALANCED_POWER_ACCURACY

blackkara
  • 4,900
  • 4
  • 28
  • 58