views:

336

answers:

1

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 have 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(); 
+1  A: 

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.

CaseyB
I found (relatively similar) solution to post DialogBuilding code to "Parent" view via ParentView.post(new Runnable() {...}) method.Thanx!
Jox