The last callback in the lifecycle of an activity is onDestroy()...

Asked 8 years ago Updated 8 years ago 1044 views

1 Answer


1

to understand this scenario let's look at the example - 

@Override
public void onCreate(Bundle savedInstanceState){
//calling super class
 super.onCreate(savedInstanceState);
//some work here
//calling finish()
finish();
}
@Override
public void onResume(){
//you need to tell the super class about this invocation, so
super.onResume();
//do your work
}
@Override
public void onPause(){
//you need to tell the super class about this invocation, so
super. onPause();
//do your work
}
@Override
public void onStop(){
//you need to tell the super class about this invocation, so
super. onStop();
}
@Override
public void onDestroy(){
//you need to tell the super class about this invocation, so
super. onDestroy ();
}

when the user calls the finish() method this will directly trigger the onDestroy() method without going through onPause() and onStop().


Write Your Answer