android.view.WindowLeaked [英] android.view.WindowLeaked
本文介绍了android.view.WindowLeaked的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
inviteBu.setOnClickListener(新View.OnClickListener(){
@覆盖
公共无效的onClick(视图v){
// TODO自动生成方法存根
如果(ChoiceList.size()大于0)
{
LayoutInflater厂= LayoutInflater.from(MobileConnectActivity.this);
最后查看textEntryView = factory.inflate(R.layout.invite_dialog,NULL);
最后的EditText等=(EditText上)textEntryView.findViewById(R.id.usercontent_edit);
直径=新AlertDialog.Builder(MobileConnectActivity.this)
.setTitle(的getString(R.string.invite_input_content))
.setView(textEntryView)
.setPositiveButton(的getString(R.string.invite_send),新DialogInterface.OnClickListener(){
公共无效的onClick(最终DialogInterface对话,诠释whichButton){
dialog.dismiss();
如果(et.getText()的toString()== NULL和放大器;&安培; et.getText()等于()。)
{
Toast.makeText(getApplicationContext(),的getString(R.string.invite_content_check),Toast.LENGTH_SHORT).show();
}
其他{
新的AsyncTask<虚空,虚空,字符串>(){
CustomDialog mProgressBar =新CustomDialog(MobileConnectActivity.this,R.style.dialog);
在preExecute保护无效(){
mProgressBar.show();
};
保护无效onCancelled(){
mProgressBar.hide();
};
@覆盖
保护字符串doInBackground(空... PARAMS){
选择列表= removeDuplicateList(选择列表);
的for(int i = 0; I< ChoiceList.size();我++)
{
Log.i(AAA,+ ChoiceList.get(ⅰ));
sendSMS(ChoiceList.get(ⅰ),et.getText()的toString());
}
返回确定;
}
保护无效onPostExecute(字符串响应){
mProgressBar.hide();
如果(响应!= NULL){
Toast.makeText(getApplicationContext(),的getString(R.string.invite_succeed),Toast.LENGTH_SHORT).show();
意向意图=新的意图();
intent.setClass(MobileConnectActivity.this,inviteMainActivity.class);
startActivity(意向);
MobileConnectActivity.this.finish();
} 其他 {
//mHelper.showResponseErrorMessage(response);
意向意图=新的意图();
intent.setClass(MobileConnectActivity.this,inviteMainActivity.class);
startActivity(意向);
完();
}
};
}。执行();
}
}
})
.setNegativeButton(的getString(R.string.invite_cancel),新DialogInterface.OnClickListener(){
公共无效的onClick(DialogInterface对话,诠释whichButton){
/ *用户点击取消,以便做一些东西* /
}
})。显示();
}
其他
{
Toast.makeText(getApplicationContext(),的getString(R.string.invite_choice_check),Toast.LENGTH_SHORT).show();
}
}
});
它给我:
3月7号至21号:36:24.519:E /窗口管理器(23240):活动com.portaura.myaura.invite.MobileConnectActivity渗漏窗口com.android.internal.policy.impl .PhoneWindow $ DecorView @ 405c32d0最初此处添加
3月七号至21号:36:24.519:E /窗口管理器(23240):android.view.WindowLeaked:活动com.portaura.myaura.invite.MobileConnectActivity渗漏窗口com.android.internal.policy.impl.PhoneWindow$DecorView@405c32d0最初这里加入
。3月7号至21日:36:24.519:E /窗口管理器(23240):在android.view.ViewRoot< INIT>(ViewRoot.java:266)
3月七号至21号:36:24.519:E /窗口管理器(23240):在android.view.WindowManagerImpl.addView(WindowManagerImpl.java:174)
3月七号至21号:36:24.519:E /窗口管理器(23240):在android.view.WindowManagerImpl.addView(WindowManagerImpl.java:117)
3月七号至21号:36:24.519:E /窗口管理器(23240):在android.view.Window $ LocalWindowManager.addView(Window.java:424)
3月七号至21号:36:24.519:E /窗口管理器(23240):在android.app.Dialog.show(Dialog.java:241)
3月七号至21号:36:24.519:E /窗口管理器(23240):在com.portaura.myaura.invite.MobileConnectActivity $ 3 $ 1 $ 1.on preExecute(MobileConnectActivity.java:161)
3月七号至21号:36:24.519:E /窗口管理器(23240):在android.os.AsyncTask.execute(AsyncTask.java:391)
3月七号至21号:36:24.519:E /窗口管理器(23240):在com.portaura.myaura.invite.MobileConnectActivity $ 3 $ 1.onClick(MobileConnectActivity.java:201)
3月七号至21号:36:24.519:E /窗口管理器(23240):在com.android.internal.app.AlertController $ ButtonHandler.handleMessage(AlertController.java:165)
3月七号至21号:36:24.519:E /窗口管理器(23240):在android.os.Handler.dispatchMessage(Handler.java:99)
3月七号至21号:36:24.519:E /窗口管理器(23240):在android.os.Looper.loop(Looper.java:130)
3月七号至21号:36:24.519:E /窗口管理器(23240):在java.lang.reflect.Method.invokeNative(本机方法)
3月七号至21号:36:24.519:E /窗口管理器(23240):在java.lang.reflect.Method.invoke(Method.java:507)
解决方案
窗口泄漏的异常通常是由不正确驳回对话框引起的。 也就是说,如果你打算辞退的AsyncTask的Onpostexecute一个对话框,并创建它已经结束了它会抛出一个窗口泄漏的活动。请确保你在的onPause dimisss活动的对话框。
inviteBu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(ChoiceList.size()>0)
{
LayoutInflater factory = LayoutInflater.from(MobileConnectActivity.this);
final View textEntryView = factory.inflate(R.layout.invite_dialog, null);
final EditText et =(EditText) textEntryView.findViewById(R.id.usercontent_edit);
dia= new AlertDialog.Builder(MobileConnectActivity.this)
.setTitle(getString(R.string.invite_input_content))
.setView(textEntryView)
.setPositiveButton(getString(R.string.invite_send), new DialogInterface.OnClickListener() {
public void onClick(final DialogInterface dialog, int whichButton) {
dialog.dismiss();
if(et.getText().toString()==null && et.getText().equals("") )
{
Toast.makeText(getApplicationContext(), getString(R.string.invite_content_check), Toast.LENGTH_SHORT).show();
}
else{
new AsyncTask<Void, Void, String>() {
CustomDialog mProgressBar = new CustomDialog(MobileConnectActivity.this, R.style.dialog);
protected void onPreExecute() {
mProgressBar.show();
};
protected void onCancelled() {
mProgressBar.hide();
};
@Override
protected String doInBackground(Void... params) {
ChoiceList=removeDuplicateList(ChoiceList);
for(int i=0;i<ChoiceList.size();i++)
{
Log.i("aaa",""+ChoiceList.get(i));
sendSMS(ChoiceList.get(i), et.getText().toString());
}
return "OK";
}
protected void onPostExecute(String response) {
mProgressBar.hide();
if (response != null ) {
Toast.makeText(getApplicationContext(), getString(R.string.invite_succeed), Toast.LENGTH_SHORT).show();
Intent intent = new Intent();
intent.setClass(MobileConnectActivity.this, inviteMainActivity.class);
startActivity(intent);
MobileConnectActivity.this.finish();
} else {
//mHelper.showResponseErrorMessage(response);
Intent intent = new Intent();
intent.setClass(MobileConnectActivity.this, inviteMainActivity.class);
startActivity(intent);
finish();
}
};
}.execute();
}
}
})
.setNegativeButton(getString(R.string.invite_cancel), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
/* User clicked cancel so do some stuff */
}
}).show();
}
else
{
Toast.makeText(getApplicationContext(), getString(R.string.invite_choice_check), Toast.LENGTH_SHORT).show();
}
}
});
it give me :
07-21 03:36:24.519: E/WindowManager(23240): Activity com.portaura.myaura.invite.MobileConnectActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405c32d0 that was originally added here
07-21 03:36:24.519: E/WindowManager(23240): android.view.WindowLeaked: Activity com.portaura.myaura.invite.MobileConnectActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView@405c32d0 that was originally added here
07-21 03:36:24.519: E/WindowManager(23240): at android.view.ViewRoot.<init>(ViewRoot.java:266)
07-21 03:36:24.519: E/WindowManager(23240): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:174)
07-21 03:36:24.519: E/WindowManager(23240): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:117)
07-21 03:36:24.519: E/WindowManager(23240): at android.view.Window$LocalWindowManager.addView(Window.java:424)
07-21 03:36:24.519: E/WindowManager(23240): at android.app.Dialog.show(Dialog.java:241)
07-21 03:36:24.519: E/WindowManager(23240): at com.portaura.myaura.invite.MobileConnectActivity$3$1$1.onPreExecute(MobileConnectActivity.java:161)
07-21 03:36:24.519: E/WindowManager(23240): at android.os.AsyncTask.execute(AsyncTask.java:391)
07-21 03:36:24.519: E/WindowManager(23240): at com.portaura.myaura.invite.MobileConnectActivity$3$1.onClick(MobileConnectActivity.java:201)
07-21 03:36:24.519: E/WindowManager(23240): at com.android.internal.app.AlertController$ButtonHandler.handleMessage(AlertController.java:165)
07-21 03:36:24.519: E/WindowManager(23240): at android.os.Handler.dispatchMessage(Handler.java:99)
07-21 03:36:24.519: E/WindowManager(23240): at android.os.Looper.loop(Looper.java:130)
07-21 03:36:24.519: E/WindowManager(23240): at java.lang.reflect.Method.invokeNative(Native Method)
07-21 03:36:24.519: E/WindowManager(23240): at java.lang.reflect.Method.invoke(Method.java:507)
解决方案
Window leaked exceptions are usually caused by dialogs which are not dismissed properly. ie if you are planning to dismiss a dialog in Onpostexecute of asynctask and the activity that created it has ended it will throw a window leak. Make sure you dimisss dialog in onPause of the activity.
这篇关于android.view.WindowLeaked的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文