onCreate method is called every time on Activity whenever screen is rotated. Is it just onCreate being called again or whole activity is re-created?
onCreate method is called every time on Activity whenever screen is rotated. Is it
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It is not just onCreate(). When the screen is rotated, the activity is paused, stopped, and restarted. See this question for more info:
Activity lifecycle – onCreate called on every re-orientation
If the question is “Why does this happen?” the answer has to do with functionality inside of Android’s activities and windows. More specifically, android currently does not have a way to move, resize, and relayout each and every view when the orientation is changed. To make handling this scenario possible, the simpler implementation of just tearing down the activity and bringing it back up in a different orientation was implemented.