According to the documentation:
An activity can frequently transition in and out of the foreground—for example, onPause() is called when the device goes to sleep or when a dialog appears.
I have an activity with a button. When I tap on the button a dialog appears. I expected onPause method was called when the dialog comes up and then onResume method called when the dialog is dismissed. But none of them are called.
findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
MyDialog myDialog = new MyDialog();
myDialog.show(getFragmentManager(),myDialog.TAG);
}
});
@Override
protected void onResume() {
super.onResume();
Toast.makeText(this,"ON RESUME ACTIVITY",Toast.LENGTH_SHORT).show();
}
@Override
protected void onPause() {
super.onPause();
Toast.makeText(this,"ON PAUSE ACTIVITY",Toast.LENGTH_SHORT).show();
}
Does anyone know why are these methods not being called? Thanks