解开迷惑——Android Context究竟是什么
2014-11-05 10:39
543 查看
Android应用开发常会用到context,但是对于初学者来说,context的概念很抽象。那么Context究竟有什么用以及怎么用呢?
首先看SDK对Context下的定义:
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.
从这段话可以看出,Context是一个抽象类,通过它我们可以获取应用程序的资源和类,也可以做应用级的操作,如:启动activity,发送广播,接收intent信息等。
那么Context怎么用呢?
1.何时创建
1⃣️创建Application对象时,而且整个App共用一个Application对象。
2⃣️创建Activity对象时。
3⃣️创建Service对象时。
……待续
ref:http://www.xcoder.cn/html/mobile/android/2013/0316/2436.html
http://www.2cto.com/kf/201109/103998.html
首先看SDK对Context下的定义:
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.
从这段话可以看出,Context是一个抽象类,通过它我们可以获取应用程序的资源和类,也可以做应用级的操作,如:启动activity,发送广播,接收intent信息等。
那么Context怎么用呢?
1.何时创建
1⃣️创建Application对象时,而且整个App共用一个Application对象。
2⃣️创建Activity对象时。
3⃣️创建Service对象时。
……待续
ref:http://www.xcoder.cn/html/mobile/android/2013/0316/2436.html
http://www.2cto.com/kf/201109/103998.html
相关文章推荐
- Android的Context究竟是什么东西?
- android中的context究竟是什么?
- Android Launcher研究(二)-----------Launcher为何物,究竟是干什么的?
- Android Launcher研究(二)-----------Launcher为何物,究竟是干什么的?
- android中的context是起什么作用的?
- Android Support 包里究竟有什么
- [高级]Android Launcher研究(二)-----------Launcher为何物,究竟是干什么的?
- Android Launcher研究(二)-----------Launcher为何物,究竟是干什么的?
- [Android Pro] Android Support 包里究竟有什么
- Android中,Context,什么是Context?
- 【Android】Support 包里究竟有什么
- Android Context 是什么?
- Android Launcher研究(二)-----------Launcher为何物,究竟是干什么的?
- Android中,Context,什么是Context?
- Android Launcher-------Launcher为何物,究竟是干什么的?
- Android下Context、Activity、Application之间有什么区别
- Android Launcher研究(二)-----------Launcher为何物,究竟是干什么的?
- Android Launcher研究(二)-----------Launcher为何物,究竟是干什么的
- android中的context是什么
- xmlns:tools="http://schemas.android.com/tools"以及tools:context=".ConfActivity"是什么意思