android - 结合使用ProgressDialog和线程时,应用程序因方向更改而崩溃

标签 android orientation oncreate crash

->我在第一个 Activity 中实现了线程。并利用进度对话框也做了。因此,现在在(仅该屏幕的)定向期间,我的应用程序崩溃了-给出了内存泄漏的异常。作为解决方案,我从这里才知道我应该把

android:configChanges="keyboardHidden|orientation"

但是现在我的 Activity 的onCreate()方法没有被调用,因此我有必要在directionChanges上调用此方法。那么在这个阶段我该怎么办?

最佳答案

查看此博客:

http://blog.doityourselfandroid.com/2010/11/14/handling-progress-dialogs-and-screen-orientation-changes/

在stackoverflow上还有其他类似的问题:
How to handle screen orientation change when progress dialog and background thread active?

如果使用第一个选项,我已经体验到模拟器存在一个错误,该错误使它两次调用onCreate()-导致崩溃,但是在实际设备上不应该成为问题。

关于android - 结合使用ProgressDialog和线程时,应用程序因方向更改而崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7358265/

相关文章:

github - 如何避免 Github 在我的 readme.md 中旋转我的 jpg?

python - python中的水平图

android - 如何在 Eclipse 中更改 xml "layout"区域的方向

android - 如果 Activity 正在完成,如何防止调用 onCreate/onCreateView 方法

android - 使用 xml drawable 渲染问题

android - 我应该在 android sqlite 中使用 "query"+ "update/insert"还是 "insert/replace"?

java - android 在 fragment 中使用什么代替 onRestart()

android - 如何检测方向变化但让 android 处理它们?

android - 如何为 Android 中的 View 分配动态 ID?

android - 使用 Android 备份服务备份 Cordova 应用程序