I have been developing an application for a few months now and getting ready to go to release. I have been using the Motorola Xoom with Android 4.0.4 for testing throughout the process and everything has worked without fail. I purchased a Nexus 7 from Google (running Jelly Bean 4.1) and I am now getting all kinds of problems with the activity life cycle when the device sleeps or turns off.
I created a new project for the sole purpose of checking the life cycle and this is the results I came up with. The following code is a sample of what I have done in each of the life cycle methods.
@Override
protected void onPause() {
Log.i("TEST", "onPause()");
super.onPause();
}
Results from Xoom (expected results)
---------- Program Launch -------------
onCreate(null)
onStart()
onResume()
---------- Turn Off Screen ------------
onPause()
onSaveInstanceState(not null)
onStop()
---------- Turn Screen On -------------
onReStart()
onRestoreInstanceState(not null)
onResume()
Results from Nexus 7 (unexpected results)
---------- Program Launch -------------
onCreate(null)
onStart()
onResume()
---------- Turn Off Screen ------------
onPause()
onSaveInstanceState(not null)
onStop()
onDestroy()
onCreate(not null)
onStart()
onRestoreInstanceState(not null)
onResume()
onPause()
---------- Turn Screen On -------------
OnResume()
onPause()
onSaveInstanceState(not null)
onStop()
onDestroy()
onCreate(not null)
onStart()
onRestoreInstanceState(not null)
onResume()
Again, these results are from a brand new project with no code changes other than the Log statements in each of the methods. Why are there so many additional, unnecessary method calls when the Nexus 7 gets turned off and back on? It seems to be completely destroying the application and then recreating.
For completeness sake, when using the home button and then relaunching the application, the life cycle seems to be consistent between devices.
Thanks in advance for any help. Wayne