Coming soon - Get a detailed view of why an account is flagged as spam!
view details

This post has been de-listed

It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.

42
Is it good practice to keep Activity and Context as member variables in Non-Activity classes?
Post Body

Hey guys!

To explain my question I would like to give more specific example.

Let's say that I want to implement some type of functionality and wrap it up in Helper class and initialize it on Acitivity's onCreate.

So naturally when I initialize that Helper object in Activity I might want to pass Context or Activity(this) as parameter, because that object has to store that Context/Activity because at some point some of the methods might need Context/Activity. Let's say findViewById(...). It's kinda bothering because I end up with bunch of Activity/Context instances flouting around.

I'm not really sure was I able to explain my concerns here but, this does not feel right. Also I see weird memory leaks on some devices.

Author
Account Strength
100%
Account Age
7 years
Verified Email
Yes
Verified Flair
No
Total Karma
86,816
Link Karma
18,003
Comment Karma
68,584
Profile updated: 6 days ago
Posts updated: 10 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
5 years ago