Can't get multiple location updates

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

Can't get multiple location updates

Postby vimana » Mon Jul 27, 2009 12:42 am

Hi,

The following code works in the emulator if I manually send GPS coordinates, but the problem is that the after 2 location updates the program no longer responds to subsequent gps coordinate updates.
Ie. Run program in debug mode -> use ddms to send gps coord manually (works) -> use ddms to send gps coord manually (works) -> subsequent attempts to send gps coord manually does not work
See code below:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. package com.lbs;
  3.  
  4.  
  5.  
  6. import android.app.Activity;
  7.  
  8. import android.content.Context;
  9.  
  10. import android.location.Location;
  11.  
  12. import android.location.LocationListener;
  13.  
  14. import android.location.LocationManager;
  15.  
  16. import android.location.LocationProvider;
  17.  
  18. import android.os.Bundle;
  19.  
  20. import android.util.Log;
  21.  
  22.  
  23.  
  24. public class LocationTest extends Activity {
  25.  
  26.        
  27.  
  28.         private LocationListener locationListener = new LocationListener()
  29.  
  30.         {
  31.  
  32.  
  33.  
  34.                 @Override
  35.  
  36.                 public void onLocationChanged(Location location) {
  37.  
  38.                         Log.e("GPSLogger", location.getLatitude() + " " + location.getLongitude());
  39.  
  40.                 }
  41.  
  42.  
  43.  
  44.                 @Override
  45.  
  46.                 public void onProviderDisabled(String provider) {
  47.  
  48.                         // TODO Auto-generated method stub
  49.  
  50.                        
  51.  
  52.                 }
  53.  
  54.  
  55.  
  56.                 @Override
  57.  
  58.                 public void onProviderEnabled(String provider) {
  59.  
  60.                         // TODO Auto-generated method stub
  61.  
  62.                        
  63.  
  64.                 }
  65.  
  66.  
  67.  
  68.                 @Override
  69.  
  70.                 public void onStatusChanged(String provider, int status, Bundle extras) {
  71.  
  72.                         // TODO Auto-generated method stub
  73.  
  74.                        
  75.  
  76.                 }
  77.  
  78.                
  79.  
  80.         };
  81.  
  82.        
  83.  
  84.     /** Called when the activity is first created. */
  85.  
  86.     @Override
  87.  
  88.     public void onCreate(Bundle savedInstanceState) {
  89.  
  90.         super.onCreate(savedInstanceState);
  91.  
  92.         setContentView(R.layout.main);
  93.  
  94.        
  95.  
  96.         LocationManager lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);
  97.  
  98.         lm.setTestProviderStatus(LocationManager.GPS_PROVIDER, LocationProvider.AVAILABLE, null, System.currentTimeMillis());
  99.  
  100.         lm.setTestProviderEnabled(LocationManager.GPS_PROVIDER, true);
  101.  
  102.        
  103.  
  104.         lm.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
  105.  
  106.     }
  107.  
  108. }
  109.  
  110.  
Parsed in 0.037 seconds, using GeSHi 1.0.8.4


Suspending all threads I notice the following:
Object.wait(long, int) line: not available [native method]
MessageQueue(Object).wait() line: 288
MessageQueue.next() line: 148
Looper.loop() line: 110
ActivityThread.main(String[]) line: 3948
....

Any suggestions would be much appreciated. I'm stumped.
Thanks
vimana
Freshman
Freshman
 
Posts: 2
Joined: Mon Jul 27, 2009 12:34 am

Top

Postby Lore » Mon Sep 14, 2009 11:12 pm

If this is the same bug I was encountering it is related to the emulator's settings for date & time. You need to go
to the settings menu on the emulator and under date & time change time zone manually instead of leaving it on the automatic option. After that you should be able to do an arbitrary number of manual gps fix's. It wont show up though unless it is a different location from the last fix.

Hope that helps
Lore
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Sep 14, 2009 11:07 pm
Location: Oregon

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests