Difference between Activity Context and Application Context

前端 未结 7 964
耶瑟儿~
耶瑟儿~ 2020-11-22 07:51

This has me stumped, I was using this in Android 2.1-r8 SDK:

ProgressDialog.show(getApplicationContext(), ....);

and also in



        
7条回答
  •  孤独总比滥情好
    2020-11-22 08:29

    Use getApplicationContext() if you need something tied to a Context that itself will have global scope.

    If you use Activity, then the new Activity instance will have a reference, which has an implicit reference to the old Activity, and the old Activity cannot be garbage collected.

提交回复
热议问题