如何显示警告信息,如果我无法与网址握手, 我正在下面的字段中传递一个URL,如果我无法满足该网址(网址为404 gatway错误)。我需要一个警告框
忘记进入onpost执行,它只会在后台停留,但如何在后台执行警告 - 我的代码
private class CheckTypesTask extends AsyncTask<Void, Void, Void> {
ProgressDialog asyncDialog = new ProgressDialog(MainActivity.this);
@Override
protected void onPreExecute() {
// set message of the dialog
asyncDialog.setMessage("Please Wait...");
// show dialog
asyncDialog.setCancelable(false);
asyncDialog.show();
super.onPreExecute();
}
@Override
protected Void doInBackground(Void... arg0) {
try {
userna = user.getText().toString();
passwd = pass.getText().toString();
String serial = Build.SERIAL;
Log.e("login method", userna + " " + passwd + "" + serial);
;
SoapObject request = new SoapObject(NAMESPACE, METHOD_NAME);
PropertyInfo propInfo1 = new PropertyInfo();
propInfo1.setName("conidential");
propInfo1.setValue(user.getText().toString().trim());
propInfo1.setType(String.class);
request.addProperty(propInfo1);
PropertyInfo propInfo2 = new PropertyInfo();
propInfo2.setName("conidential");
propInfo2.setValue(pass.getText().toString().trim());
propInfo2.setType(String.class);
request.addProperty(propInfo2);
PropertyInfo propInfo3 = new PropertyInfo();
propInfo3.setName("DeviceId");
propInfo3.setValue(serial);
propInfo3.setType(String.class);
request.addProperty(propInfo3);
SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envelope.dotNet = true;
envelope.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
androidHttpTransport.debug = true;
androidHttpTransport.call(SOAP_ACTION, envelope);
// Object response = (Object)envelope.getResponse();
// SoapPrimitive response =
// (SoapPrimitive)envelope.getResponse();
SoapObject response = (SoapObject) envelope.getResponse();
String status = response.getProperty("Status").toString();
if (status.equals("1")) {
storename = response.getProperty("StoreName").toString();
}
Log.i("myApp", status.toString() + "Storename:" + storename);
typeStatus = status.toString();
} catch (Exception e) {
e.printStackTrace();
Log.e("exception at doin", e.toString());
}
return null;
}
@Override
protected void onPostExecute(Void result) {
// hide the dialog
asyncDialog.dismiss();
try {
if (typeStatus.equals("1")) {
///////////doing my stuff
super.onPostExecute(result);
}
}
}
}
答案 0 :(得分:0)
你可以尝试将runOnUIthread放入doInBackground(Void ... arg0){
{{1}}