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("");
}
}
你的問題的一些代碼將是有益的。 –
查看編輯過的帖子。 –