what is Android Context and why is it needed

Possible Duplicate:
What is Context in Android?

I would like to know what exactly Android's Context is, and why it is needed. I know it's related to class and each class has a unique context. I have seen in some code which passes a Context when calling methods of another class. I don't understand why it is needed. Please help.


a Context is:

Interface to global information about an application environment. This is an abstract class whose implementation is provided by the Android system. 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.

Ref: http://developer.android.com/reference/android/content/Context.html


All classes does not have an android context. Their is an application context, and activity c contexts. A context is used for a lot of things, but most often it is just to load and access resources.

See: http://developer.android.com/reference/android/content/Context.html for more info.


The android context holds information about your application's environment.

You might want to take a look at the official reference in order to understand which information is being held by your context and what operations you can do with it.

链接地址: http://www.djcxy.com/p/91356.html

上一篇: Android中的“背景”含义是什么?

下一篇: 什么是Android上下文以及为什么需要它