【发布时间】:2013-05-22 01:08:05
【问题描述】:
我收到此错误:已泄漏窗口 com.android.internal.policy.impl.PhoneWindow$DecorView@46029dd0 最初添加在此处 我在模拟器中有网络连接,通过打开网站查看浏览器。
我在 processdialog 行遇到错误。
@SuppressLint("NewApi")
private class TheTask extends AsyncTask<Void, Void, Void> {
@Override
protected void onPreExecute() {
dialog = ProgressDialog.show(Register.this, "",
"Registering... Please wait...", true);
}
@Override
protected Void doInBackground(Void... params) {
request = new SoapObject(NAMESPACE, METHOD_NAME);
name = new PropertyInfo();
name.setName("Name");
name.setValue(Name);
name.setType(String.class);
request.addProperty(name);
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) {
textValidation.setText(e.toString());
}
return null;
}
@Override
protected void onPostExecute(Void result) {
if (dialog != null) {
dialog.dismiss();
dialog = null;
}
}
}
}
【问题讨论】:
-
请将
Void改为void -
可能应用程序崩溃是因为您试图从
doInBackground更新 UI 元素所以使用onPostExecute来更新 ui 元素而不是 doInBackground -
是的,仪式……它显示了来自 doInBackground 的 UI 元素的 bcz……非常感谢。