0

I use this solution to get latitude and longitude. It works on my main activity, but not in an other activity of my project. Do you know why ? It's a fullscreen activity which use the device camera...

gpsTracker.latitude; //Always 0

Please ask me for more detail, but maybe one of you know the problem.

Community
  • 1
  • 1
hayj
  • 1,159
  • 13
  • 21
  • Is the other activity extending your main activity? check the context and if it is being passed to other activities...or is the code called statically.... Also, please take a look at [this question too](http://stackoverflow.com/questions/23962769/android-gps-incorrect-location-data-on-query) , esp if you are using gps tracker – Pararth Jun 06 '14 at 13:38
  • It means that your device doesn't have a lastKnownLocation yet. THat class isn't really good- it hides some complexity, but does so poorly. FOr example, there's no way to verify that a valid latitude or longitude exists, or if its giving possibly stale data. I'd advise against using it. – Gabe Sechan Jun 06 '14 at 14:51

1 Answers1

0

Thank you for your comments but the solution is to use

void android.app.Activity.runOnUiThread(Runnable action)

The class GPSTracker does not display the exception, I missed it :

Can't create handler inside thread that has not called Looper.prepare()

hayj
  • 1,159
  • 13
  • 21