为什么我们真的需要通过上下文的一些元素是什么getApplicationContext()
,getBaseContext()
,MainActivity.this
之间的区别?android中的上下文是什么?
-3
A
回答
1
这被问及几次回答。
请参阅此问题:What is Context in Android?和接受的答案:https://stackoverflow.com/a/3572553/1820695
对于各种Context
访问方法之间的差异(getApplicationContext()
,getBaseContext()
,this
在Activity
等)看到了这个问题:Android - what's the difference between the various methods to get a Context?
0
如果我们通过文档
接口关于应用程序环境的全局信息去。 是一个抽象类,其实现由Android系统提供。它允许访问特定应用的资源和 类,以及向上调用应用程序级的操作,如 开展活动,广播和接收意图等
简单地说目前它的上下文应用程序/对象的状态。它可以让新创建的对象了解到底发生了什么。通常你调用它来获取关于你的程序(活动,封装/应用)
对于getApplicationContext()和getBaseContext(之差)请参阅this
相关问题
- 1. 什么是Android中的上下文
- 2. 什么是iPhone中的上下文?
- 3. 什么是SQLAlchemy上下文中的“instrumentation”?
- 4. MSTests中的上下文是什么?
- 5. 什么是CUDA上下文?
- 6. 我的上下文是什么?
- 7. 用于PreferenceManager.getDefaultSharedPreferences的上下文是什么?
- 8. 什么是em的上下文?
- 9. 什么是上下文?为什么在odoo中使用?
- 10. WCF在以下上下文中的含义是什么?
- 11. Android上的UID是什么?
- 12. nodejs文件中的函数的上下文是什么?
- 13. 什么是图形上下文? (iOS)
- 14. 什么是3种绑定上下文?
- 15. 什么是上下文切换?
- 16. 什么是上下文切换时间?
- 17. 什么是AspectJ上下文绑定?
- 18. 什么是对象文件上下文中的LLVM虚拟节?
- 19. android在广播接收器的onReceive()中传递的上下文是什么
- 20. 什么是Android上的“滑块中断”
- 21. 在android中有什么不同的上下文?
- 22. “.build()”在Google Analytics for Android的上下文中做了什么?
- 23. 通过Manifest文件定义的Android Receiver的上下文是什么?
- 24. 数组中的函数的上下文是什么?
- 25. 这个例子中的“this”的上下文是什么?
- 26. iframe中的框架的jQuery/javascript上下文是什么?
- 27. 什么是JavaScript事件循环的上下文中的堆?
- 28. Android中的ODEX文件是什么?
- 29. Android中的.dex文件是什么?
- 30. 什么是android中的mainfest文件?
有很多的问题在这里是有答案的另一部分信息你正在寻找。看看[这里](http://stackoverflow.com/questions/3572463/what-is-context-in-android)的完全相同的问题。也看看答案[这里](http://stackoverflow.com/questions/4128589/difference-between-activity-context-and-application-context),[这里](http://stackoverflow.com/questions/7298731 /何时调用活动上下文或应用程序上下文)和[这里](http://stackoverflow.com/questions/5018545/getapplication-vs-getapplicationcontext) – ebarrenechea 2013-02-21 16:04:11