What is the order that garbage collection collects references in this case:
Activity -> Button -> Anonymous class for onClickListener.
How all this is garbage collected when onClickListener holds reference to the wrapping class (Activity)?
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.
If you’re never passing your Button or listener outside the Activity, then this does not effect the GC process at all. They will all get garbage collected when the Activity is no longer referenced anywhere.