从源码中Activity 的定义来理解 Activity
首先我们来看下源码中源于Activity的定义:
Context是一个抽象类,因此可以知道Activity其实就是一个Context,并实现了一些接口,如何理解Context呢?
Context 俗称上下文,在很多对象定义中我们都用到了Context,例如ImageViewimageView = new ImageView(this); 这里的this就是当前Activity所在的Context,源码中对Context的解释如下:
Interface to global information about anapplication environment. This is an abstract class whose implementation isprovided by the Android system. It allows access to application-specificresources and classes, as well as up-calls for application-level operationssuch as launching activities, broadcasting and receiving intents, etc.
Context只是一个接口,真正实现Context功能的是ContexImpl类,为了了解Context具体有什么作用,我们先来了解下Context中定义了哪些接口: