Difference between Activity Context and Application Context

前端 未结 7 972
耶瑟儿~
耶瑟儿~ 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:20

    The reason I think is that ProgressDialog is attached to the activity that props up the ProgressDialog as the dialog cannot remain after the activity gets destroyed so it needs to be passed this(ActivityContext) that also gets destroyed with the activity whereas the ApplicationContext remains even after the activity gets destroyed.

提交回复
热议问题