Skip to content Skip to sidebar Skip to footer

How To Get Context In Android Service Class

I am getting the following error when i try to read a XML file from the memory and into an object. Seems like problem with getting the Context. Can anyone tell me whats wrong with

Solution 1:

You should do this not in the constructor, but only between (inclusive) onCreate() and onDestroy().

Solution 2:

If you are using a service you are supposed to write that code in onStartCommand, not in the constructor

Post a Comment for "How To Get Context In Android Service Class"