从服务内螺纹显示ProgressDialog [英] Show ProgressDialog from thread inside the Service

查看:110
本文介绍了从服务内螺纹显示ProgressDialog的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个服务,注册 ContentObserver 。当我的 ContentObserver 检测到更改其设置服务的布尔变量设置为true。我也有一个运行中睡了一段时间,醒来检查变量的服务。

I have a Service with registered ContentObserver. When my ContentObserver detects changes it sets Service's boolean variable to true. I also have a Thread running in the service which sleeps for some time and wakes up to check that variable.

当它检测到更改,它需要一些时间来处理其他一些code,我需要在延迟期间表现出 ProgressDialog 。我怎样才能做到这一点?

When it detects change it needs some time to process some other code and I need to show ProgressDialog during the delay. How can I do this?

推荐答案

你的问题的本质是,你希望你的服务来发送某种信息给你的UI(显示一个对话框加载)。

The essence of your question is that you want your service to send a message of some kind to your UI (to show a loading dialog).

有要去这个四个(或更多)的方式:

There are four (or more) ways of going about this:


  • 意图:让您的服务发送的意图,你的活动

  • AIDL

  • 使用服务对象本身(如单身)

  • 有你的活动是一个广播接收器

这些选项似乎熟悉:<一href=\"http://stackoverflow.com/questions/2463175/how-to-have-android-service-communicate-with-activity\">How有Android的服务与活动沟通

您必须要在这些选项阅读并随你挑。

You'll have to read up on those options and take your pick.

这篇关于从服务内螺纹显示ProgressDialog的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆