Google終於在Android API v2中添加了位置更改的回調!但是,我無法直觀地使其發揮作用,Google沒有太多的文檔。有沒有人得到它的工作?我還需要什麼?在Google Maps中使用新的OnMyLocationChangeListener Android API v2
public class ... extends SupportMapFragment implements GoogleMap.OnMyLocationChangeListener {
GoogleMap map;
LocationManager locationManager;
String provider;
@Override
public void onActivityCreated(android.os.Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
map = getMap();
if (map != null) {
Criteria criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
locationManager =(LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);
provider = locationManager.getBestProvider(criteria, false);
}
}
@Override
public void onResume() {
super.onResume();
while(map == null) {
map = getMap();
map.setMyLocationEnabled(true);
map.setOnMyLocationChangeListener(this);
}
}
@Override
public void onMyLocationChange(Location loc) {
//implementation
}
}
小心解釋你爲什麼低估了我? – brainmurphy1 2013-02-27 04:16:46
我結束了使用這一個http://stackoverflow.com/questions/13742551/how-to-get-my-location-changed-event-with-google-maps-android-api-v2 – brainmurphy1 2013-07-02 00:33:12