我使用函数 onLocationChanged 来识别用户的位置,我希望它发生在手机的每一次移动Android
究竟何时调用该函数?
我的代码如下所示:
locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationListener = new GPSLocationListener();
locationManager.requestLocationUpdates(LocationManager.GPS_PROVIDER, 0, 0, locationListener);
GPS定位监听器:
public class GPSLocationListener extends DroidGap implements LocationListener
{
@Override
public void onLocationChanged(Location location) {
AlertDialog.Builder alt_bld = new AlertDialog.Builder(this);
alt_bld.setMessage("onLocationChanged");
AlertDialog alert = alt_bld.create();
alert.show();
}
@Override
public void onProviderDisabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onProviderEnabled(String provider) {
// TODO Auto-generated method stub
}
@Override
public void onStatusChanged(String provider, int status, Bundle extras) {
// TODO Auto-generated method stub
}
}
警报 onLocationChanged 永远不会出现。