Android:在WebService调用后显示对话框

时间:2011-04-11 07:35:07

标签: android multithreading web-services dialog

我正在尝试从wbservice收到结果后显示一个对话框。 显示Toast工作正常,但不是对话框。怎么了?

progress = ProgressDialog.show(ServiceProperties.this,
            "Please wait...", "Saving configuration...");
    new Thread(new Runnable() {
        public void run() {
    String Res = null;
            ESMWebService ESMws = new ESMWebService();
    try {
                ESMws.AddParam("ComputerName", ComputerName);
                ESMws.AddParam("ServiceName", ServiceName);
                ESMws.AddParam("Properties", Properties);
                Res = ESMws.ExecuteMethod("ChangeService");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (XmlPullParserException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
            if (Res != null) {
            runOnUiThread(new Runnable() {
                        @Override
                        public void run() {
                        new AlertDialog.Builder(serviceActivity.getApplicationContext())
                            .setTitle("Save")
                            .setMessage("Saving service configuration succeeded.")
                            .setNeutralButton("Close", new DialogInterface.OnClickListener() {
                                public void onClick(DialogInterface dlg, int arg) {
                                    serviceActivity.finish();
                                }
                            })
                            .show();
                            progress.dismiss();
                    }

0 个答案:

没有答案