I'm using the usual technique of extending Application in order to store global constants.
So within my activities, I can simply do (in oncreate()):
W = (WcmApplication) getApplicationContext();
However, this doesn't work for broadcast receivers:
The method getApplicationContext() is undefined for the type MyReceiver
So, thinking I was being clever, I tried to do:
W = (WcmApplication) context;
... but that throws an error at runtime saying my broadcast receiver is not allowed to access that context
Not giving up, I try this:
W = (WcmApplication) Context.getApplicationContext();
... no dice
So I ended up having to do:
W = (WcmApplication)context.getApplicationContext() ;
... and that works nicely, however I have no idea why.
Can someone explain why one works and not the others?
Thank you!