2017-12-13 10 views
2

장소 목록이 있습니다. 사용자가 모든 항목을 클릭하면 또 다른 Activity은지도 활동에 항목을 표시합니다. 항목 클릭에 LatLng을 putExtra과 함께 보냅니다.지도 활동이 뒷좌석에서 멈추지 않습니다

모든 것이 정상적으로 작동하지만 내 문제는지도 활동에서 사용자가 백 프레스를하면지도가 다시 표시되고 일종의 새로 고침 (사용자가 두 번 누르면지도 활동을 종료 함)입니다.

kill의 경우 finish() 또는 다른 죽이는 페이지가 작동하지 않습니다!

첫 번째 활동

lv = getListView(); 
lv.setOnItemClickListener(new AdapterView.OnItemClickListener() { 
    @Override 
    public void onItemClick(AdapterView<?> parent, final View view, int position, long id) { 
    Intent intent = new Intent(getApplicationContext(),BimarestanMAP.class); 
    switch(position) { 
     case 0 : 
     intent.putExtra("name", str1); 
     intent.putExtra("lat", bim1a); 
     intent.putExtra("lan", bim1l); 
     startActivity(intent); 
     break; 
    } 

지도 활동

initilizeMap(); 
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); 
googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); 
googleMap.setMapType(GoogleMap.MAP_TYPE_NORMAL); 
googleMap.setMyLocationEnabled(true); 
googleMap.getUiSettings().setZoomControlsEnabled(true); 
googleMap.getUiSettings().setCompassEnabled(true); 
googleMap.getUiSettings().setRotateGesturesEnabled(true); 
googleMap.getUiSettings().setZoomGesturesEnabled(true); 
Bundle bundle = getIntent().getExtras(); 
str1 = bundle.getString("name"); 
final double lat = bundle.getDouble("lat"); 
final double lan = bundle.getDouble("lan"); 

Marker marker = googleMap.addMarker(new MarkerOptions() 
    .position(new LatLng(lat, lan)) 
    .title(str1) 
    .icon(BitmapDescriptorFactory.fromResource(R.drawable.marker))); 
marker.showInfoWindow(); 
googleMap.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(lat, lan), 15)); 

@Override 
protected void onResume() { 
    super.onResume(); 
    initilizeMap(); 
} 

private void initilizeMap() { 
    if (googleMap == null) { 
    googleMap = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap(); 
    // check if map is created successfully or not 
    if (googleMap == null) { 
     Toast.makeText(getApplicationContext(), "sorry no map!", Toast.LENGTH_SHORT).show(); 
    } 
    } 
} 
} 
+0

가능한 복제 ([구글에서 종료가 안드로이드의 의도 매핑] https://stackoverflow.com/questions/30838812/exit-from-google-maps-intent-in -android) –

+0

initilizeMap()을 두 번 호출하는 이유는 무엇입니까? – Lucky

답변

0
해결

, 그리고 감사; 올린 날짜 : intent.addFlags (Intent.FLAG_ACTIVITY_CLEAR_TOP);

in item intent;

+1

다른 사람이 옳은 답을 줄 때 자신의 답변을 게시하지 마십시오. 그것을 정답으로 받아들이십시오. – Dharmishtha

0

추가 다음과 같은 의도 플래그

Intent intent = new Intent(Activity1.this, Activity2.class); 
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK); 
    intent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY); 
    startActivity(intent); 
    finish();