异常:
<span style="font-size:18px;">: android.view.WindowLeaked: Activity dianshi.matchtrader.activity.MainActivity has leaked window com.android.internal.policy.impl.PhoneWindow$DecorView</span>{4374e4c0 V.E..... R.....I. 0,0-1026,692} that was originally added here
at android.view.ViewRootImpl.<init>(ViewRootImpl.java:391)
at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:258)
at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
at android.app.Dialog.show(Dialog.java:323)
at dianshi.matchtrader.view.MyAlertDialog.buildDialog(MyAlertDialog.java:89)
at dianshi.matchtrader.view.MyAlertDialog.tipDialog(MyAlertDialog.java:112)
at dianshi.matchtrader.activity.LoginActivity.alertConnect(LoginActivity.java:546)
at dianshi.matchtrader.activity.LoginActivity.access$500(LoginActivity.java:54)
at dianshi.matchtrader.activity.LoginActivity$5.handleMessage(LoginActivity.java:456)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5314)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)
</span> at dalvik.system.NativeStart.main(Native Method)
异常出现地方:
//弹出提示对话框
dialog = new MyAlertDialog(AppManager.getAppManager().currentActivity());
dialog.tipDialog(getResources().getString(R.string.login_netFail), positiveBtnStr, negativeBtnStr, new MyAlertDialog.DialogCallBack() {
@Override
public void onEnSure() {
Activity currentActivity = AppManager.getAppManager().currentActivity();
//跳转到登录页面
Intent intent = new Intent(currentActivity,LoginActivity.class);
startActivity(intent);
currentActivity.finish();
}
异常原因:
activity has leaked window 翻译过来是 这个activity有被泄露的窗口
什么情况下会出现泄露的窗口?
一般是Dialog 或者popwindow 等这种基于一个activity才能弹出的窗口被泄露了.泄露的发生情况在一个处在弹出对话框的情况下 ,这个activity被finish了,但是这个弹出框没有被显式关闭,所以就被泄露了
异常解决:
//弹出提示对话框
dialog = new MyAlertDialog(AppManager.getAppManager().currentActivity());
dialog.tipDialog(getResources().getString(R.string.login_netFail), positiveBtnStr, negativeBtnStr, new MyAlertDialog.DialogCallBack() {
@Override
public void onEnSure() {
//关闭对话框,这个一定要加上的,防止内存泄露
dialog.dismiss();
Activity currentActivity = AppManager.getAppManager().currentActivity();
//跳转到登录页面
Intent intent = new Intent(currentActivity,LoginActivity.class);
startActivity(intent);
currentActivity.finish();
}