GeoPoint List in LocationListener!

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

GeoPoint List in LocationListener!

Postby curro » Mon Mar 22, 2010 5:45 pm

Hello, I'm declaring a GeoPoint list in my activity:
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. List<GeoPoint> listaPuntos;
Parsed in 0.030 seconds, using GeSHi 1.0.8.4


and I'm having a LocationListener to get updates on my location by GPS. Each time there is a location update I want to add that location to my list by converting to a GeoPoint like this:

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2.    private class miLocListener implements LocationListener {
  3.  
  4.         public void onLocationChanged(Location arg) {
  5.  
  6.                 lastLocation = arg;
  7.  
  8.                
  9.  
  10.                 Double latitud  = arg.getLatitude() * 1E6;
  11.  
  12.                 Double longitud = arg.getLongitude() * 1E6;
  13.  
  14.                 GeoPoint tmpPoint = new GeoPoint( latitud.intValue(), longitud.intValue() );                   
  15.  
  16.  
  17.  
  18.                 listaPuntos.add(tmpPoint);                             
  19.  
  20.         }
  21.  
  22.                 @Override
  23.  
  24.                 public void onProviderDisabled(String arg0) {}
  25.  
  26.                 @Override
  27.  
  28.                 public void onProviderEnabled(String provider){}
  29.  
  30.                 @Override
  31.  
  32.                 public void onStatusChanged(String provider, int status, Bundle extras){}      
  33.  
  34.     }
  35.  
  36.  
  37.  
  38.  
Parsed in 0.033 seconds, using GeSHi 1.0.8.4


But the application keeps crashing when adding the point to the list: listaPuntos.add(tmpPoint);

If I remove that line, everything works fine but I don't get the list!

Please Help!!
curro
Freshman
Freshman
 
Posts: 7
Joined: Thu Mar 04, 2010 3:17 pm

Top

Postby eppinator » Tue Mar 23, 2010 11:50 am

Could it be that you forgot to initialize the list?
Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. List<GeoPoint> listaPuntos = new ArrayList<GeoPoint>();
Parsed in 0.035 seconds, using GeSHi 1.0.8.4

What exception do you get? (See LogCat)
eppinator
Junior Developer
Junior Developer
 
Posts: 10
Joined: Thu Feb 11, 2010 1:00 pm

Postby curro » Tue Mar 23, 2010 4:48 pm

So ashamed, can't believe I missed that. Thanks!
curro
Freshman
Freshman
 
Posts: 7
Joined: Thu Mar 04, 2010 3:17 pm

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 4 guests