2013-04-08 43 views
-2

我想定期获取当前位置 - (以五(5)秒为间隔),我正在使用适用于Android的Google Maps V2。在Google地图V2中定期获取位置更新

+0

您需要使用位置管理,requestlocationupdates()来获取当前位置 – Abhi 2013-04-08 17:46:56

+0

http://mattgemmell.com/2008/ 12月8日/什么具备的,你试了/ – TronicZomB 2013-04-08 18:08:23

回答

1

此代码更新的位置每5秒(5000毫秒)或50计:

LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE); 
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 5000, 50, locationListener); 
LocationListener locationListener = new MyLocationListener(); 

// ... 

public class MyLocationListener implements LocationListener { 

    public void onLocationChanged(Location location) { 
     currentLocation = new GeoPoint(location); 
     reDrawMap(); 
    } 

    public void onProviderDisabled(String provider) { 
    } 

    public void onProviderEnabled(String provider) { 
    } 

    public void onStatusChanged(String provider, int status, Bundle extras) { 
    } 
} 
相关问题