Context —— getApplicationContext()、getBaseContext()、this的区别
2016-09-05 14:52
399 查看
转自http://stackoverflow.com/questions/1026973/android-whats-the-difference-between-the-various-methods-to-get-a-context(英文)
getbasecontext()返回由构造函数指定或setBaseContext()设置的上下文。
getApplicationContext ()方法在应用程序要被摧毁时,返回整个应用程序生命周期的应用上下文。
this应用上下文返回activity的当前上下文,属于activity。当它被摧毁时,activity也被摧毁。
getBaseContext()是
ContextWrapper中的方法。
getbasecontext()返回由构造函数指定或setBaseContext()设置的上下文。
相关文章推荐
- getApplication()、getApplicationContext()、getBaseContext()、MainActivity.this、this、getContext()之间的区别
- this、getApplicationContext和getBaseContext的区别
- getApplicationContext()、getBaseContext()、this的区别
- Android 中this、getContext()、getApplicationContext()、getApplication()、getBaseContext() 之间的区别
- getApplicationContext()、Activity.this、 getBaseContext区别
- android中getApplicationContext()、this、getApplication()、getBaseContext之间的区别
- getApplication()、getApplicationContext()、getBaseContext()、MainActivity.this、this、getContext()之间的区别
- getApplicationContext()、getbasecontext()与this的区别
- Android:getApplicationContext()、Activity.this、 getBaseContext()区别
- getApplicationContext()、Activity.this、 getBaseContext区别
- getApplicationContext()、Activity.this、 getBaseContext区别
- getContext() , getApplicationContext() , getBaseContext() and “this”的区别
- getApplication()、getApplicationContext()、getBaseContext()、MainActivity.this、this、getContext()之间的区别
- getApplication()、getApplicationContext()、getBaseContext()、MainActivity.this、this、getContext()之间的区别
- Android 中 getApplicationContext()、this、getBaseContext()之间的区别
- getApplicationContext()、getBaseContext()、this的区别
- Android 中this、getContext()、getApplicationContext()、getApplication()、getBaseContext() 之间的区别
- android中获取context的多种方法的区别(this,getbasecontext(),getApplicationcontext())
- Context 的作用、getApplicationContext()、Activity.this、 getBaseContext区别 和 Application用途
- getApplicationContext()、Activity.this、 getBaseContext区别