本文介绍了活动已泄漏最初此处添加窗口com.android.internal.policy.impl.PhoneWindow$DecorView@46029dd0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我收到此错误:泄露最初此处添加窗口com.android.internal.policy.impl.PhoneWindow$DecorView@46029dd0我在模拟器的网络连接,打开网站,看看浏览器。
我收到错误的processdialog行。
@燮pressLint(NewApi)
私有类TheTask扩展的AsyncTask<虚空,虚空,虚空> {
@覆盖
在preExecute保护无效(){
对话框= ProgressDialog.show(Register.this,,
注册......请稍候......,真正的);
}
@覆盖
保护无效doInBackground(虚空...... PARAMS){
要求=新SoapObject(命名空间METHOD_NAME);
NAME =新的PropertyInfo();
name.setName(姓名);
name.setValue(名称);
name.setType(为String.class);
request.addProperty(名称);
SoapSerializationEnvelope envp =新SoapSerializationEnvelope(
SoapEnvelope.VER11);
envp.dotNet = TRUE;
envp.setOutputSoapObject(要求);
HttpTransportSE androidHttpTransport =新HttpTransportSE(URL);
尝试 {
androidHttpTransport.call(SOAP_ACTION,envp);
SoapPrimitive响应=(SoapPrimitive)envp.getResponse();
响应= response.toString();
}赶上(例外五){
textValidation.setText(e.toString());
}
返回null;
}
@覆盖
保护无效onPostExecute(无效的结果){
如果(对话!= NULL){
dialog.dismiss();
对话框= NULL;
}
}
}
}
解决方案
这个错误会发生,如果你的活动已被破坏,但你对话框仍呈现。所以,你必须在添加了这些code本活动的的onDestroy()
@覆盖
公共无效的onDestroy(){
super.onDestroy();
如果(对话!= NULL){
dialog.dismiss();
对话框= NULL;
}
}
I am getting this error : has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@46029dd0 that was originally added hereI have net connection in emulator, check it out browser by opening websites.
I am getting error at the line of 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;
}
}
}
}
解决方案
This error will happen if your activity has been destroyed but you dialog is still showing.So You have added these code in your activity's onDestroy()
@Override
public void onDestroy() {
super.onDestroy();
if (dialog != null) {
dialog.dismiss();
dialog = null;
}
}
这篇关于活动已泄漏最初此处添加窗口com.android.internal.policy.impl.PhoneWindow$DecorView@46029dd0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!