Android 警告提示:Activity has leaked window xxxxx was originally added here

出错的原因是由于手机在横、竖屏切换时导致的,处理办法:

1、在AndroidManifest.xml里面对出错的Activity加上:

 android:launchMode="singleInstance" android:configChanges="orientation|keyboardHidden"


2、在出错的Activity里面加上代码:

    @Override 
    public void onConfigurationChanged(Configuration newConfig)
    { 
        super.onConfigurationChanged(newConfig);
        if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE)
        {
        	//land
        }
        else if (this.getResources().getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT)
        {
        	//port
        }
    }

 

 

 

你可能感兴趣的:(Android 警告提示:Activity has leaked window xxxxx was originally added here)