Show dialog only using Context instead of Activity instance

后端 未结 4 985
轻奢々
轻奢々 2021-02-04 22:36

I could show dialog if I uses an Activity instance but when I uses Context or Application Context instance Dialog is not showing.

AlertDialog.Builder builder = n         


        
4条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-04 23:03

    For some reason [at least in android 2.1] a toast can be on the application context but not a progress dialog

    MyActivity.this is an activity specific context which does not crash

    MyActivity.getApplicationContext() is global and will crash progress bars and in later versions also toasts.

提交回复
热议问题