Cannot get location like google maps on Phone

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

Cannot get location like google maps on Phone

Postby nguyenhonglam » Fri Apr 02, 2010 4:41 am

I use SamSung i5700, (sdk 3)
my code to get location by GPS

Syntax: [ Download ] [ Hide ]
Using java Syntax Highlighting
  1.  
  2. public GeoPoint get_GeoPoint_Phone() {
  3.  
  4.                 locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
  5.  
  6.                 Criteria criteria = new Criteria();
  7.  
  8.                 criteria.setAccuracy(Criteria.ACCURACY_FINE);
  9.  
  10.                 criteria.setAltitudeRequired(false);
  11.  
  12.                 criteria.setBearingRequired(false);
  13.  
  14.                 criteria.setCostAllowed(true);
  15.  
  16.                 criteria.setPowerRequirement(Criteria.POWER_LOW);
  17.  
  18.  
  19.  
  20.                
  21.  
  22.                 if (locationManager == null)
  23.  
  24.                         return null;
  25.  
  26.                
  27.  
  28.                 String provider = locationManager.getBestProvider(criteria, true);
  29.  
  30.                 Double latPoint = locationManager.getLastKnownLocation(provider).getLatitude();
  31.  
  32.                 Double lngPoint = locationManager.getLastKnownLocation(provider)
  33.  
  34.                                 .getLongitude();
  35.  
  36.                 locationManager.requestLocationUpdates(provider,MapControler.minTime, MapControler.minDistance, this);
  37.  
  38.                 GeoPoint gp = new GeoPoint((int) (latPoint * 1E6),
  39.  
  40.                                 (int) (lngPoint * 1E6));
  41.  
  42.  
  43.  
  44.                 return gp;
  45.  
  46.         }
  47.  
  48.  
Parsed in 0.034 seconds, using GeSHi 1.0.8.4

my code usually get old location (same "cache"), how to solve above problem?, thanks
nguyenhonglam
Freshman
Freshman
 
Posts: 7
Joined: Wed Feb 24, 2010 2:39 am

Top

Return to Map Problems

Who is online

Users browsing this forum: No registered users and 2 guests