Search code examples
androidandroid-intentservicebroadcastreceiverandroid-context

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


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)?


Solution

  • public abstract void onReceive(Context context, Intent intent)
    

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