我有一个问题。我有2个MapActivity。首先,我在地图上显示一些地方,并让我的listView与那些地方。当我点击listView时,它会打开第二个地图,并在地图上显示一个地方,并在该地点的某些信息下显示。更新位置很好,但是当我按下“后退”按钮时,它会显示未更新位置的第一个活动。我的问题是如何在第二次按下按钮时在第一次活动中更新位置?这是我做了什么:onBackPressed位置更新android
@Override
public void onBackPressed() {
Intent data = new Intent();
data.putExtra("Latitude", location.getLatitude());
data.putExtra("Longitude", location.getLongitude());
setResult(RESULT_OK,data);
super.onBackPressed();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(requestCode == request_Code){
if(resultCode == RESULT_OK){
Location location = new Location(provider);
location.setLatitude(data.getDoubleExtra("Latitude", 0));
location.setLongitude(data.getDoubleExtra("Longitude", 0));
listener.onLocationChanged(location);
}
}
super.onActivityResult(requestCode, resultCode, data);
}
这是解决我的问题
我修复它...创建新的位置实例...感谢人 – Jovan
添加为您的问题的答案。 – Ronnie
接受最能帮助您的答案 – Sameer