android - Java variables declaration -
i little bit confused program flow of android activity, in java main method executes first while in android oncreate methods gets called first, variables defined @ class level? how declared/initialized when activity starts executing, saying oncreate gets called first. can initialize these variables in inner class , use values outside of inner class?
actually oncreate() method called first say. activity flows this
oncreate - >onstart -> onresume
at point activity visible user
similarly when activity ends
onpause -> onstop ->ondestroy
so answering question. variables in class level not dependent, on these methods. because scope whole activity ie; onstart ondestroy . can initialize them in oncreate so. if want change there values on moving next activity should in onresume. activity lifecycle follows
you have freedom rest in java
Comments
Post a Comment