2017-10-20 4 views
1

응용 프로그램이 백그라운드에서 다시 시작하는 경우 콜백이 필요하지만 항상 onResume()은 활동 시작이라고하는 경우 onResume().다시 시작 활동 인 경우에만

Intent i = new Intent(this, Spedizione.class); 
i.putExtra("codice", result.getText()); 
startActivity(i); 

onResume 코드 :

내가 가진 활동을 열

@Override 
    protected void onResume() { 
    super.onResume(); 
    AlertDialog.Builder builder = new AlertDialog.Builder(this); 
      builder.setMessage("Are you sure?").setPositiveButton("Yes", dialogClickListener) 
        .setNegativeButton("No", dialogClickListener).show(); 
    } 

공개 활동 onResume() 항상에 AlertDialog를 호출 할 때뿐만 아니라 응용 프로그램은 배경에서 다시 시작하는 경우, 그 이유는 무엇입니까?

응용 프로그램이 백그라운드에서 다시 열리는 경우에만 콜백 만하면됩니다.

답변

3

OnResume()은 매번 호출되는 Activity Lifecycle 메서드입니다. onRestart()를 호출하거나 firstTimeCall을 검사하기위한 부울 값을 유지하여 조건을 처리 할 수 ​​있습니다.

+0

설명서에 설명되어 있습니다. https://developer.android.com/guide/components/activities/activity-lifecycle.html#alc –

관련 문제