读书人

关于Context的懂得

发布时间: 2012-10-05 15:34:34 作者: rapoo

关于Context的理解

Context

?

翻译成中文大概是:“上下文,背景”的意思。

这是一个抽象类,这个类的具体左右是什么呢?

?

Api文档是这样描述的:

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.

?

下面摘自http://stackoverflow.com/questions/3572463/what-is-context-in-android的描述

As the name suggests, its the context of current state of the application/object. It lets newly created objects understand what has been going on. Typically you call it to get information regarding another part of your program (activity, package/application)

You can get the context by invoking?getApplicationContext(),?getContext(),getBaseContext()?or?this?(when in the activity class).

Typical uses of context:

读书人网 >移动开发

热点推荐