D
Deleted User
Guest
Hi,
I would like to test my app and make sure my instance state handling is working properly.
To do this, I've ran my app in the emulator, simulated a phone call, answered, hung up and been brought back to my application.
I've overridden the onSaveInstanceState method:
I have NOT overridden the onRestoreInstanceState method.
When I begin my test, the onSaveInstanceState method is invoked and my Bundle is written to. However, when I hang up the phone, it appears that my original Activity is brought back. As I said, I have NOT overridden the onRestoreInstanceState method. I've no code to restore the instance. Yet, everything on the screen is the way I left it. The EditTexts are populated, the AlertDialog that got thrown up while the phone was up was showing, everything was there. How is this possible and how can I do a real test?
Thanks for your help
I would like to test my app and make sure my instance state handling is working properly.
To do this, I've ran my app in the emulator, simulated a phone call, answered, hung up and been brought back to my application.
I've overridden the onSaveInstanceState method:
Code:
@Override
protected void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
// save screen state
outState.putString(LOGIN_USER_NAME, mUsernameTextbox.getText().toString());
outState.putString(LOGIN_USER_PASS, mPasswordTextbox.getText().toString());
}
I have NOT overridden the onRestoreInstanceState method.
When I begin my test, the onSaveInstanceState method is invoked and my Bundle is written to. However, when I hang up the phone, it appears that my original Activity is brought back. As I said, I have NOT overridden the onRestoreInstanceState method. I've no code to restore the instance. Yet, everything on the screen is the way I left it. The EditTexts are populated, the AlertDialog that got thrown up while the phone was up was showing, everything was there. How is this possible and how can I do a real test?
Thanks for your help