标签:
public class MyActivity extends Activity {
public void method() {
mContext = this; // since Activity extends Context
mContext = getApplicationContext();
}
}
this 是因为Activity 扩展了Context,其生命周期是Activity 创建到销毁;
getApplicationContext 取得的Context是和Application关联的生命周期是应用的创建到销.
[转]this和getApplicationContext区别
标签:
原文地址:http://www.cnblogs.com/qvbrgw/p/4388429.html