GPS position always (0, 0) in onLocationChanged()

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

GPS position always (0, 0) in onLocationChanged()

Postby kameltreiber84 » Wed Feb 03, 2010 3:29 pm

Hi there!
Im trying to emulate a GPS signal und the emulator.
The onLocationChanged event is actually triggered:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.         @Override
  3.  
  4.         public void onLocationChanged(Location location) {
  5.  
  6.                 // handle a location update
  7.  
  8.                 Log.i("LOCATION UPDATE", "LOCATION UPDATE RECEIVED " + location.getLongitude() + " " + location.getLatitude());
  9.  
  10.                 // TODO location is always 0 by the emulator <img src="http://www.anddev.org/images/smilies/sad.png" alt=":(" title="Sad" /> test here
  11.  
  12.                 output.setText("Längengrad: " + location.getLongitude() + "\nBreitengrad: " + location.getLatitude() + "\ntime: " + System.currentTimeMillis());
  13.  
  14.         }
  15.  
  16.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


The ouput tells me the location is alway 0, but in the emulator in typed in:
Decimal:
Longitude: -122,084095
Latitue: 37,422006
(exchange of , with . does not work either)

What could be wrong here?
Thanks, regards
kameltreiber84
Junior Developer
Junior Developer
 
Posts: 18
Joined: Tue Jan 26, 2010 10:24 pm

Top

Postby kameltreiber84 » Fri Feb 05, 2010 11:32 am

Hi there.
I actually found out I can set the coordinates by connection via telnet in windoes.

When I try to built up the connection in java I am not able to connect to the emulator.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. Socket telnetSocket = null;
  3.  
  4.                     String localhost = "127.0.0.1";
  5.  
  6.                     try
  7.  
  8.                     {
  9.  
  10.                       telnetSocket = new Socket();
  11.  
  12.                       telnetSocket.connect(new InetSocketAddress(localhost, 5554));
  13.  
  14.  
Parsed in 0.032 seconds, using GeSHi 1.0.8.4


The cnnection is refused, meanwhile the emulator accepts connections via the windows console (telnet localhost 5554)

Whats going wrong here?

Thanks, regards.
kameltreiber84
Junior Developer
Junior Developer
 
Posts: 18
Joined: Tue Jan 26, 2010 10:24 pm

Postby kameltreiber84 » Fri Feb 05, 2010 3:13 pm

Well I got the connection.

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. try {
  3.  
  4.                         Socket telnetSocket = new Socket("10.0.2.2", 5554);
  5.  
  6.                         new PrintStream(telnetSocket.getOutputStream()).print("geo fix 12 12");
  7.  
  8.  
Parsed in 0.035 seconds, using GeSHi 1.0.8.4


The establishment of the connection is working fine.
But the location event is not triggered.


No ideas?
kameltreiber84
Junior Developer
Junior Developer
 
Posts: 18
Joined: Tue Jan 26, 2010 10:24 pm

Postby nicholas.hauschild » Sat Feb 06, 2010 1:41 am

Hello kameltreiber84,

I believe you are using the emulator console incorrectly. You should not need to connect to the emulator console with telnet in your Java code, but rather, by using a telnet client that is external to Java.

On Linux, you would simply open a terminal window, type 'telnet 5554', and you would be connected, then you could type your commands. I believe the process on Windows would be very similar.

If I were to venture a guess, I would try this:

-Start your emulator
-Click Start (in Windows, not the emulator :))
-Click Run
-type 'cmd' and hit enter
-type 'telnet 5554'
-type in your 'geo fix' command

Now that is a guess, I have not telnet'd on Windows before.

Best of luck, and please share with whether or not that worked.
-Nick
nicholas.hauschild
Master Developer
Master Developer
 
Posts: 310
Joined: Fri Dec 04, 2009 4:50 am

Postby kameltreiber84 » Sat Feb 06, 2010 3:03 am

Hey!
Thanks.
Yes that works. But I am interested in doing in Simmulation with a lot of updates. In a telnet client, updates can be done manually only.

Best regards.
kameltreiber84
Junior Developer
Junior Developer
 
Posts: 18
Joined: Tue Jan 26, 2010 10:24 pm

Re: GPS position always (0, 0) in onLocationChanged()

Postby mannders » Wed Feb 10, 2010 3:16 am

kameltreiber84 wrote:Hi there!
Im trying to emulate a GPS signal und the emulator.
The onLocationChanged event is actually triggered:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.         @Override
  2.         public void onLocationChanged(Location location) {
  3.                 // handle a location update
  4.                 Log.i("LOCATION UPDATE", "LOCATION UPDATE RECEIVED " + location.getLongitude() + " " + location.getLatitude());
  5.                 // TODO location is always 0 by the emulator <img src="http://www.anddev.org/images/smilies/sad.png" alt=":(" title="Sad" /> test here
  6.                 output.setText("Längengrad: " + location.getLongitude() + "\nBreitengrad: " + location.getLatitude() + "\ntime: " + System.currentTimeMillis());
  7.         }
  8.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


The ouput tells me the location is alway 0, but in the emulator in typed in:
Decimal:
Longitude: -122,084095
Latitue: 37,422006
(exchange of , with . does not work either)

What could be wrong here?
Thanks, regards


I'm having the exact same problem. I read somewhere that the first update is always (0,0), but my listener doesn't even notice the ones after the first. Any ideas?

Code's pretty straight forward:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.  
  3.  
  4. //....
  5.  
  6. lm = (LocationManager) getSystemService(Context.LOCATION_SERVICE);    
  7.  
  8. locationListener = new MyLocationListener();
  9.  
  10. lm.requestLocationUpdates(
  11.  
  12.             LocationManager.GPS_PROVIDER,
  13.  
  14.             1000,
  15.  
  16.             0,
  17.  
  18.             locationListener);
  19.  
  20. //....
  21.  
  22.  
  23.  
  24. private class MyLocationListener implements LocationListener
  25.  
  26.     {
  27.  
  28.         @Override
  29.  
  30.         public void onLocationChanged(Location loc) {
  31.  
  32.             if (loc != null) {                
  33.  
  34.                 System.out.println("Location changed : Lat: " + loc.getLatitude() + " Lng: " + loc.getLongitude());
  35.  
  36.             }
  37.  
  38.         }
  39.  
  40.  
  41.  
  42.         //............
  43.  
  44.     }
  45.  
  46.  
Parsed in 0.038 seconds, using GeSHi 1.0.8.4


So I'm changing the coordinates in DDMS, and the first time it tells me "Location changed : Lat: 0 Lng: 0". I then send some other coordinates, and nothing happens. I've waited for half an hour for it to update, but it won't :(
mannders
Once Poster
Once Poster
 
Posts: 1
Joined: Wed Feb 10, 2010 3:04 am

Top

Postby kameltreiber84 » Wed Feb 10, 2010 10:43 am

Well,
I am receiving the replz from the emulator>
@Android console: tzpe a list of commands."

And after writing:

printwriter .println("geo fix " + longitude + " " + latitude);

the inputstream replies with "OK".

But the location update in the activity is not triggered. An ideas?

Best regards.
kameltreiber84
Junior Developer
Junior Developer
 
Posts: 18
Joined: Tue Jan 26, 2010 10:24 pm

Re: GPS position always (0, 0) in onLocationChanged()

Postby petr » Tue Jun 08, 2010 11:41 am

Hi guys,
If you're using eclipse, this should solve the problem:
http://code.google.com/p/android/issues ... id=915#c11

good luck!
Petr
petr
Once Poster
Once Poster
 
Posts: 1
Joined: Tue Jun 08, 2010 11:38 am

Re: GPS position always (0, 0) in onLocationChanged()

Postby Eagle Eye » Tue Jun 15, 2010 9:03 pm

Thx man! I was looking for this for a long time:D
Eagle Eye
Junior Developer
Junior Developer
 
Posts: 14
Joined: Sun May 23, 2010 6:38 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests