Can't use locationManager.getCurrentLocation

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

Can't use locationManager.getCurrentLocation

Postby wen » Mon Mar 23, 2009 3:33 pm

I'm trying to use locationManager.getCurrentLocation ,

but there is an error says .."The method getCurrentLocation(String) is undefined for the type LocationManager"

can anyone help me? thanks :D
wen
Once Poster
Once Poster
 
Posts: 1
Joined: Mon Mar 23, 2009 3:23 pm

Top

Postby moderating » Thu Mar 26, 2009 1:40 am

LocationManager.getLastKnownLocation(String provider)
moderating
Freshman
Freshman
 
Posts: 2
Joined: Wed Mar 25, 2009 1:50 am

Postby Alpha-Sphere » Thu Apr 09, 2009 11:38 am

moderating wrote:LocationManager.getLastKnownLocation(String provider)


ok so getCurrentLocation doesn't exist anymore and getLastKnownLocation is what we should use now but I don't want the last know location. I want the current location. What do I do to get the current location?? :S

Should I try and get an update after a change of one feet and then stop the update or something like that??
Alpha-Sphere
Once Poster
Once Poster
 
Posts: 1
Joined: Thu Apr 09, 2009 11:28 am

Postby vf10a » Tue Jun 16, 2009 4:24 pm

Sorry to dig up an old thread but I am also interested in this. What is the recommended way to try and obtain the current position (i.e. just do one gps query and deal with result / lack thereof rather than polling)?
vf10a
Freshman
Freshman
 
Posts: 2
Joined: Tue Jun 16, 2009 4:21 pm

Postby Sowmya » Thu Jun 18, 2009 10:50 am

Try this to get current location

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1. LocationManager lm=(LocationManager)this.getSystemService(LOCATION_SERVICE);      
  2.  
  3.  lm.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 10, 10, new LocationListener(){
  4.  
  5.  
  6.  
  7.                         @Override
  8.  
  9.                         public void onLocationChanged(Location location) {
  10.  
  11.                                 // TODO Auto-generated method stub
  12.  
  13.                                
  14.  
  15.                                 log.println("onLocationChanged: lat="+location.getLatitude());
  16.  
  17.                                 log.println("onLocationChanged: lat="+location.getLongitude());                        
  18.  
  19.                         }
  20.  
  21.  
  22.  
  23.                         @Override
  24.  
  25.                         public void onProviderDisabled(String provider) {
  26.  
  27.                                 // TODO Auto-generated method stub
  28.  
  29.                                 log.println("onProviderDisabled: " +provider);
  30.  
  31.                                
  32.  
  33.                         }
  34.  
  35.  
  36.  
  37.                         @Override
  38.  
  39.                         public void onProviderEnabled(String provider) {
  40.  
  41.                                 // TODO Auto-generated method stub
  42.  
  43.                                 log.println("onProviderEnabled: " +provider);
  44.  
  45.                                
  46.  
  47.                         }
  48.  
  49.  
  50.  
  51.                         @Override
  52.  
  53.                         public void onStatusChanged(String provider, int status,
  54.  
  55.                                         Bundle extras) {
  56.  
  57.                                 // TODO Auto-generated method stub
  58.  
  59.                                 log.println("onStatusChanged: " +provider + status);
  60.  
  61.                                
  62.  
  63.                         }
  64.  
  65.                
  66.  
  67.         });
Parsed in 0.034 seconds, using GeSHi 1.0.8.4
Sowmya
Experienced Developer
Experienced Developer
 
Posts: 51
Joined: Fri Mar 06, 2009 7:49 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 3 guests