当我运行我的应用程序时,我似乎间歇性地收到以下错误。
“活动泄漏了最初添加到此处的window com.android.internal.policy.impl.PhoneWindow$DecorView@40521348”
我所要做的就是在onCreate()方法中创建对话框,如下所示:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//Create splash-screen object and pass in width and height (width and height are defined and valid, I just removed them from this post to make it more readable)
splash = new SplashScreen(MainActivity.this, width, height);
//Create dialog that will show splash-screen
loading_dialog = new Dialog(MainActivity.this,android.R.style.Theme_Black_NoTitleBar_Fullscreen);
//Set and display splash screen view
loading_dialog.setContentView(splash);
loading_dialog.show();
}你知道问题出在哪里吗?
发布于 2013-06-19 16:45:54
您可以在onCreate中创建对话框,但不能显示它,因为activity还不可见。谷歌它,有一个例子如何做正确的地方…
发布于 2013-06-19 06:16:31
我认为您需要在显示对话框之前创建它。
您需要做的是:
loading_dialog.create().show();相反,
loading_dialog.show();我找到了类似的Q,你可以使用它们
发布于 2013-06-19 16:55:26
这可能是因为您在关闭Activity之前没有取消()对话框。尝试在onStop()方法中对对话框执行cancel()。这应该会有帮助。希望能有所帮助。
https://stackoverflow.com/questions/17179829
复制相似问题