0
我使用soap方法发送请求。然后,我将字符串变量中的响应存储在doInBackground中,然后检查onPostExecute条件。 但正如我一步一步检查它,我才知道这是清除值onPostExecute。 如何解决这个问题?AsyncTask在onPostExecute中清除响应
protected Void doInBackground(Void... args) {
request = new SoapObject(NAMESPACE, METHOD_NAME);
username = new PropertyInfo();
username.setName("UserName");
username.setValue(Username);
username.setType(String.class);
request.addProperty(username);
password = new PropertyInfo();
password.setName("Password");
password.setValue(Password);
password.setType(String.class);
request.addProperty(password);
SoapSerializationEnvelope envp = new SoapSerializationEnvelope(
SoapEnvelope.VER11);
envp.dotNet = true;
envp.setOutputSoapObject(request);
HttpTransportSE androidHttpTransport = new HttpTransportSE(URL);
try {
androidHttpTransport.call(SOAP_ACTION, envp);
SoapPrimitive response = (SoapPrimitive) envp.getResponse();
Response = response.toString();
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
if (dialog != null) {
dialog.dismiss();
dialog = null;
}
if (Response.equals("Fail")) {
etPassword.setText("");
textValidation.setText("UserName Or Password is Wrong.");
} else {
etUsername.setText("");
etPassword.setText("");
}
}
你的问题的一些代码将是有益的。 –
查看编辑过的帖子。 –