is it appropriate to define instance variables on the top of the class or we need to define them in onResume/onPause of the activity
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.
Depends on the type of variable. There are some things (e.g. Views) that are not available until the layout is initialized. For others (e.g. resources) you need a Context so you’d have to wait until
onCreateas well.If you just want to define an integer or a String, namely, stuff that doesn’t depend on the Android framework, go nuts.