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

lifecycle

you have freedom rest in java


Comments

Popular posts from this blog

python - Subclassed QStyledItemDelegate ignores Stylesheet -

java - HttpClient 3.1 Connection pooling vs HttpClient 4.3.2 -

SQL: Divide the sum of values in one table with the count of rows in another -