我有一个主要活动,当按下此按钮时我有一个按钮,它显示地图。这很完美。
但是当我按下后退键时,我将再次进入我的主要活动,现在当我再次按下地图按钮时,它会显示整个世界地图。
我的意思是说它从头开始。
如何从 Back Stack 中完全删除我的地图活动并再次创建以再次显示我想要的地图?
或任何其他解决方案来做到这一点?
编辑:1
btn_find_atm.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
Intent intent = new Intent(NearByATM.this, Map.class);
startActivityForResult(intent, request_map);
}
});
编辑:2
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (isGooglePlayAvailable()) {
expld = new ExpandablePlaceListData();
criteria = new Criteria();
criteria.setAccuracy(Criteria.ACCURACY_FINE);
// Getting the service from context and giving to location_manager
location_manager = (LocationManager) getSystemService(LOCATION_SERVICE);
setContentView(R.layout.mapdemo);
placesTask = new PlacesTask();
getGoogleMap();
getUserLocation();
google_map.clear();
Toast.makeText(this, "Latitude:" + lat + " Longitude:" + lang,
Toast.LENGTH_LONG).show();
drawMarker();
sb = createUrl();
placesTask.execute(sb);
}
}
@Override
public void onBackPressed() {
super.onBackPressed();
Intent returnIntent = new Intent();
setResult(RESULT_OK, returnIntent);
this.finish();
}
编辑:3
private void getUserLocation() {
if (location_manager != null) {
provider = location_manager.getBestProvider(criteria, true);
location = location_manager.getLastKnownLocation(provider);
location_manager.requestLocationUpdates(provider,
Map.MIN_TIME_BW_UPDATES,
Map.MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
if (location != null) {
lat = location.getLatitude();
lang = location.getLongitude();
} else {
Toast.makeText(Map.this, "Unable to idntify location",
Toast.LENGTH_LONG).show();
lat = -22.00000;
lang = 33.0000;
}
}
}
编辑:4
当我再次按下按钮加载地图时,LogCat 会显示类似的内容。
10-19 16:47:06.048: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:06.086: I/SurfaceTexture(4887): [unnamed-4887-1](this:0x5fa6d608,api:0) detachFromContext
10-19 16:47:06.087: I/BufferQueue(4887): [unnamed-4887-1](this:0x610cd580,api:0) consumerDisconnect
10-19 16:47:06.088: I/BufferQueue(4887): [unnamed-4887-1](this:0x610cd580,api:0) ~BufferQueue
10-19 16:47:06.090: D/dalvikvm(4887): threadid=22: exiting
10-19 16:47:06.096: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:06.097: D/dalvikvm(4887): threadid=22: bye!
10-19 16:47:08.782: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.783: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.785: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.853: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.853: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.854: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.864: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.864: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.865: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.866: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.866: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.867: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.874: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0
10-19 16:47:08.882: W/Trace(4887): Unexpected value from nativeGetEnabledTags: 0