[Solved] Problem at locationManager.getCurrentLocation gps

Put problem concerning MapActivities, MapViews, Overlays and GPS in this forum.

[Solved] Problem at locationManager.getCurrentLocation gps

Postby wonglik » Tue Feb 12, 2008 6:41 pm

Hi I am trying to do rather simple thing as taking my position out of LocationManager.

The code is as simple as
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  3.  
  4.                         Location location = locationManager.getCurrentLocation("gps");
  5.  
  6.                        
  7.  
  8.                         Double lat = location.getLatitude() * 1E6;
  9.  
  10.                         Double lng = location.getLongitude() * 1E6;
  11.  
  12.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


Problem is that both lat an lng are 0.0 :cry:

does anybody has similar problem?

regards
Mateusz
wonglik
Freshman
Freshman
 
Posts: 8
Joined: Tue Feb 12, 2008 6:35 pm
Location: Poland

Top

Postby plusminus » Tue Feb 12, 2008 7:54 pm

Hello wonglik,

the first query for the gps-position somehow always returns 0 / 0. It seems to be a kick-off for the Locationmanager or sth.

On the second query it should be working correctly.

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby wonglik » Thu Feb 14, 2008 6:34 pm

Hi plusminus.

It is more or less how You mention but I do not understand it fully.
Second request really gives correct values but only if fired by registered intern. If I do few method invocations in a row it still returns nothing useful. Not sure if this just need time to starts working or there is some more magic behind the scene that I do not understand. Any way thx for help

regards
Mateusz
wonglik
Freshman
Freshman
 
Posts: 8
Joined: Tue Feb 12, 2008 6:35 pm
Location: Poland

Postby plusminus » Fri Feb 15, 2008 11:43 am

Hello wonglik,

what do you mean with:
wonglik wrote:... If I do few method invocations in a row it still returns nothing useful...


It will not return YOUR actual GPS position, but the position of a simulated Fake-Location :!:
Have a look here for a detailed explanation: :arrow: http://www.anddev.org/viewtopic.php?t=105

Regards,
plusminus
Image
Image | Android Development Community / Tutorials
User avatar
plusminus
Site Admin
Site Admin
 
Posts: 2688
Joined: Wed Nov 14, 2007 8:37 pm
Location: Schriesheim, Germany

Postby wonglik » Fri Feb 15, 2008 6:14 pm

HI

Well I understand that this is just a mock. What I mean is that if You just ask for mocked coordinates twice it will not work either.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. location = locationManager.getCurrentLocation("gps");
  3.  
  4. location = locationManager.getCurrentLocation("gps");
  5.  
  6.  
Parsed in 0.031 seconds, using GeSHi 1.0.8.4


So my I was wandering does it need some time to starts working or it needs to be triggered by some Intent. For me it is just a bit strange that getCurrentLocation() do two diffrent things separatly. It looks that one time it start the gps mock and second time it returns coordinates.
wonglik
Freshman
Freshman
 
Posts: 8
Joined: Tue Feb 12, 2008 6:35 pm
Location: Poland

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 1 guest