首页 > 代码库 > getApplicationContext()、getbasecontext()与this的区别

getApplicationContext()、getbasecontext()与this的区别

getApplicationContext() 返回应用的上下文,生命周期是整个应用,应用摧毁它才摧毁


Activity.this的context 返回当前activity的上下文,属于activity ,activity 摧毁他就摧毁


getbasecontext()返回由构造函数指定或setBaseContext()设置的上下文

getApplicationContext()、getbasecontext()与this的区别