ID : 10314
viewed : 20
Tags : androidbroadcastreceiverandroid-serviceandroid
84
Service
extends ContextWrapper
which extends Context
. Hence the Service
is a Context
. Use 'this'
keyword in the service.
72
Service
extends ContextWrapper
ContextWrapper
extends Context
So....
Context context = this;
(in Service or Activity Class)
61
Since Service
is a Context
, the variable context must be this
:
DataBaseManager dbm = Utils.getDataManager(this);
50
just in case someone is getting NullPointerException
, you need to get the context inside onCreate().
Service
is a Context
, so do this:
@Override public void onCreate() { super.onCreate(); context = this; }