【发布时间】:2013-01-28 19:06:33
【问题描述】:
我已经使用了下面的代码并且一切正常,除了 onLocationChanged 被调用,即使我坐在同一个位置。
我认为只有在我向右移动时才应该调用它?
我只想在移动一定距离后获取位置。
请帮帮我。 提前致谢。
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
locationMgr = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
locationMgr.requestLocationUpdates(LocationManager.NETWORK_PROVIDER, 0, 0,
this);
}
@Override
public void onLocationChanged(Location location) {
Toast.makeText(this, "Working!", Toast.LENGTH_SHORT).show();
if (location != null) {
double lat = location.getLatitude();
double lng = location.getLongitude();
String Text = "Latitud = " + lat + "\nLongitud = " +
lng;
Toast.makeText(getBaseContext(),Text,Toast.LENGTH_SHORT).show();
}
}
【问题讨论】:
标签: android google-maps location