I'm developing an application
right now, the problem is that when I pressed home
or open
whatsapp
from notification
and reopen the application
, it restarted from the beginning of the application
, instead of resuming
to the state it was left.
While locking and then unlocking the screen resumes to the state where it was left.
So, I tried tracing the life-cycle
between those two process (locking screen & opening other app/home).
What makes me confuse is that both process show same lifecycle
, onPause()
and onStop()
are triggered when I locked the screen or open other app/home. Then, when I returned to the app, onRestart()
and onResume()
are triggered.
If both shows the same result, why locking the screen and unlocking continued the application
, while pressing home
or another application
and reopen application
did not?
Any solution or explanation is appreciated. Thanks.
Code :
@Override
protected void onRestart(){
System.out.println("Restart");
super.onRestart();
}
@Override
protected void onResume(){System.out.println("Resume");
gamePanel.resumeActivity();
super.onResume();
}
@Override
protected void onPause(){
gamePanel.pauseMusic();
gamePanel.pauseActivity();
System.out.println("PAUSE");
super.onPause();
}
@Override
protected void onStop(){
System.out.println("STOP");
super.onStop();
}
@Override
protected void onDestroy(){
content.removeView(gamePanel);
content.removeView(editText);
gamePanel.stopMusic();
System.out.println("DESTROY");
super.onDestroy();
}