【发布时间】:2014-06-05 02:42:42
【问题描述】:
我在使用位置监听器和位置管理器时遇到问题。
我正在使用我在 Internet 上找到的课程
public class MyLocationListener implements LocationListener
{
public void onLocationChanged(Location location) {
home_text.setText("Location Change");
}
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
}
当我使用 gps 提供程序时,它工作正常
locationListener = new MyLocationListener();
locationManager = (LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER,1000,1, locationListener);
当我使用网络提供商时,onLocationChanged 只是在开始时调用了一次,并且再也没有调用过。
locationListener = new MyLocationListener();
locationManager = (LocationManager)getActivity().getSystemService(Context.LOCATION_SERVICE);
locationManager.requestLocationUpdates(LocationManager.NETWORK_PROVIDER,1000,1, locationListener);
虽然,当我使用这两种方法打开地图时,它仍然可以找到我当前的位置并更新地图。
googleMap.setMyLocationEnabled(true);
请帮帮我...
【问题讨论】:
标签: android eclipse google-maps-api-2 locationlistener