开发者

Fireing Android Dialogs from another thread without Message Loop

开发者 https://www.devze.com 2022-12-16 14:02 出处:网络
In a SurfaceView, I\'m dispatching new thread that draws on canvas within standard \"LockCanvas-Draw-unlockCanvasAndPost\" loop. (note that thread doesn\'t contains message loop).

In a SurfaceView, I'm dispatching new thread that draws on canvas within standard "LockCanvas-Draw-unlockCanvasAndPost" loop. (note that thread doesn't contains message loop).

How to show Android standard Dialog from that thread?

As thread doesn't h开发者_运维问答ave msg loop, following code doesn't work:

Builder builder = new AlertDialog.Builder(this);
builder.setTitle("Alert");
builder.setMessage("Stackoverflow!");
builder.setNegativeButton("cancel", null);
builder.show(); 


You could pass the second thread a handler that you can send a message on to the first thread that will then show the dialog.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号