How to pop up a dialog box in any activity of an android program

Any activity pops up a dialog box, then you can use the service to pop up a global one.

This is the code

Alert dialog box. A builder? A builder? =? New? Alert dialog box. Builder (Ben);

builder . seticon(r . drawable . IC);

builder . settitle(" title ");

Builder.setMessage ("prompt text");

builder . setpositivebutton(r . string . BTN _ update,? New? OnClickListener()? {

@ Overlay

Public? Invalid? onClick(DialogInterface? Dialog box, int? Which)? {

//Add button, callback event

}

);

builder . setcancelable(false); //You cannot cancel the popup box by changing the Enter key.

AlertDialog? Dialogue? =? builder . create();

dialog.getWindow()。 setType(WindowManager。 layout params . TYPE _ SYSTEM _ ALERT); //Set the popup box to global.

dialog . setcanceledontouchoutside(false); //losing focus will not disappear

dialog . show();