Android - Getting context from a Broadcast receiver onReceive() to send to

madu picture madu · Nov 7, 2010 · Viewed 41.9k times · Source

I basically want to make an intent and pass it to a service from my BroadcastReceiver's onReceive().

So far I always used View.getContext(), but here, I'm stuck. How exactly can I get the context so I can use public Intent (Context packageContext, Class<?> cls)?

Answer

Falmarri picture Falmarri · Nov 7, 2010
public abstract void onReceive(Context context, Intent intent)

onReceive gives you the context. What more do you want?