The pop-up dialog in the service is the same as the way the dialog is popped in the activity, but after the activity finishes, dialog will also close, and he is attached to the activity. In the service is not the same, the service has no interface, say Pop dialog, he attached to what?
First, look at how the dialog box pops up in the service:
dialog = new Alertdialog.builder (CTX). Create ();d Ialog.getwindow (). SetType (WindowManager.LayoutParams.TYPE_SYSTEM_ ALERT); Dialog.show (); window window = Dialog.getwindow (); Window.setcontentview (R.layout.exit_dialog); Button OK = (button) Window.findviewbyid (r.id.sure);((TextView) Window.findviewbyid (R.id.prompt_context)). SetText ( msg); Ok.setonclicklistener (new View.onclicklistener () {public void OnClick (View v) {//Destroys all activitystopself (); Exitapplication.getinstance (). exit ();}); button Cancel = (Button) Window.findviewbyid (r.id.cancel); Cancel.setonclicklistener (new View.onclicklistener () { public void OnClick (View v) {dialog.cancel ();}}); Dialog.setcancelable (FALSE);
There is such a remark on the above:
Dialog.getwindow (). SetType (WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
This is the setting of the dialog belongs to the Global, the System dialog box, in any interface will pop out.
However, when my own app quit, the service continues to run, and do not want to dialog bounce out, how to achieve it?
Need to study Ah!