HeadFirstAndroid
HeadFirstAndroid copied to clipboard
question about Activity lifecycle
Hi,When i read about Activity lifecycle in chapter 4,your book said when an Activity is paused and then rotated,how is the lifecycle going? Here i add a new button to StopWatch app,and when click the button,start a new Activity,and the new Activity‘s theme is Theme.Dialog,so when start the Activity,my StopWatchActivity is in onPause method,at this moment,I rotate my device,onStop->onDestroy->onCreate->onStart->onResume->onPause is called,but the book said onResume is not called,how to understand this?
I would recommend you use the log functions inside of each of the activity lifecycle methods, then monitor logcat while your app moves through each of them. This will give you a better understanding of exactly if/when each method is called, and in what order. onResume should be called after onStart, so what you are seeing is correct. Have a look at Google's documentation:
