Reputation: 145
Say I have an Android broadcast receiver defined on the manifest file.
What is the context I received on onReceived(Context context, ...)?
Is it going to be an instance of the Application Context?
Thanks
Upvotes: 0
Views: 57
Reputation: 1006674
I would not count on it being any particular type of Context
. It is not documented as being Application
and could very easily be some sort of ContextWrapper
. The actual class might even vary between Android versions.
If you need the Application
context, call getApplicationContext()
on the passed-in Context
. That way, you are guaranteed to get the correct object.
Upvotes: 2