Mark Freeman
Mark Freeman

Reputation: 541

Android: getting system services from within a application level library class

Hopefully someone can give me a pointer. I have an application that makes several web service calls. I'm in the middle of a refactor and I've pulled the actual calls out to a new class. The problem is that I can't seem to use:

SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this); or TelephonyManager telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);

within my class. I'm not extending anything, so I suppose the problem is that I don't have the application context. Is there a good base class that I should be extending to be able to use these or some secret to it?

Upvotes: 0

Views: 235

Answers (1)

bhups
bhups

Reputation: 14875

pass application context to this new class' constructor.

Upvotes: 1

Related Questions