How to create a dialog box in a non-UI thread in a different class?

前端 未结 2 1598
别跟我提以往
别跟我提以往 2021-01-28 09:35

I\'m developing a very simple game in android(that runs in a non-UI thread), I want to make that, when the game is over, it shows a custom dialog box with the score, but the cla

2条回答
  •  無奈伤痛
    2021-01-28 10:30

    You need to go back to the UI thread to show the dialog, but you will need a reference to the current Activity (MainActivity I assume) to access to the UI thread and to use as a Context of the dialog. Check the method runOnUiThread

提交回复
热议问题