All this is true, but it doesn't really answer the question. Why, for
example, are all these things inheriting from one class, and why is
that class named 'Context'?

I think the OP will have a better feel for what a Context is by
reading the Class Overview in the online reference, which does a
pretty good job of describing it in:

"Interface to global information about an application environment. ...
It allows access to application-specific resources and classes, as
well as up-calls for application-level operations such as launching
activities, broadcasting and receiving intents, etc."

Every mobile phone OS has something analogous to the Android Context.
But they call it different names. Qualcomm's BREW, for example, calls
it IShell (unfortunately, they complicate things by spinning off some
of the functionality into IEnv). Sprint's PictureMail called it simply
"the device handle". Handle to what? To PictureMail's view of the
entire environment view from that particular device, that particular
phone.

The OP should read the relevant page in the online reference, and note
how the APIs listed under 'methods' all fit that general description:
they are providing global information about the application
environment.

On Jul 9, 11:12 am, Mark Murphy <[email protected]> wrote:
> On Fri, Jul 9, 2010 at 2:04 PM, cindy <[email protected]> wrote:
> > A very silly question, What is Context?
>
> It is a class.
>
> > How to get it?
>
> Activity is a subclass of Context. Service is a subclass of Context.
> BroadcastReceiver gets a Context object in its onReceive() method.
> Pretty much everything else gets it from one of those three sources,
> passed along as a method parameter.
>
> --
> Mark Murphy (a Commons 
> Guy)http://commonsware.com|http://github.com/commonsguyhttp://commonsware.com/blog|http://twitter.com/commonsguy
>
> _The Busy Coder's Guide to Android Development_ Version 3.1 Available!

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to