【问题标题】:Handling progress dialog during IntentService executionIntentService 执行期间的处理进度对话框
【发布时间】:2014-01-23 19:23:08
【问题描述】:

我正在使用 IntentService、ResultReceiver 机制来执行长时间运行的任务,并在 IntentService 运行期间在我的活动中显示进度对话框。当任务在 intentService 中完成时,我会在 onReceiveResult 中向 Activity 发送适当的 resultCode 并相应地关闭进度对话框。 一切正常,除非设备方向发生变化,在此期间应用程序崩溃,活动销毁,Intent 服务尝试将 resultCode 发送到销毁的活动。

我不想停止系统在屏幕旋转时重新创建我的活动。

如何处理?

【问题讨论】:

  • 完成任务需要多长时间。如果它的 asynctask 我可以为您提供解决方案并发布您的一些活动和服务代码
  • 我们可以使用 AsyncTask 实现这一点,但也应该有这种方法的解决方案。
  • 我没有厌倦任何解决方案。对于 asynctask,我有 alex lookwood 的解决方案

标签: android progressdialog intentservice


【解决方案1】:

这是一个不推荐但可行的解决方案:

在清单中添加这一行:

android:configChanges="orientation"

看起来像

<activity android:label="@string/app_name" 
        android:configChanges="orientation|keyboardHidden" 
        android:name=".your.package">

更多信息,see this post

这也是 Reto Meier here 的更完整答案

【讨论】:

  • 引用操作“我不想停止系统在屏幕旋转时重新创建我的活动。”。我已经建议并删除了它,因为他不想停止活动娱乐
猜你喜欢
  • 1970-01-01
  • 2011-05-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-03-18
相关资源
最近更新 更多