Android的服务,使活动没有响应 [英] Android Service makes Activity not responding
问题描述
任何人都知道,可当我从活动启动服务的原因,仿真器显示消息活动不响应?
在我的服务,我开始2个线程,以便使一些任务。可能是这个问题的原因是什么?
感谢
任何人知道什么可能是原因 当我从开始服务 活动中,仿真器显示消息 活动不响应?
由于东西在你的应用程序 - 活动,服务等 - 被占用主应用程序线程
在我的服务,我开始2线程 订制一些任务。可这样一 这个问题的原因是什么?
不是直接的,没有,但你真的应该考虑使用的AsyncTask
,而不是分叉你自己的线程
这样的主应用程序线程上长时间运行工作,或用睡眠()
或忙环绑起来,将导致此异常。
anybody knows what can be the reason for when i start a service from an Activity, the emulator shows a message "the activity is not responding?"
Inside my Service i start 2 threads in order to make some tasks. can be this the cause of the problem?
Thanks
anybody knows what can be the reason for when i start a service from an Activity, the emulator shows a message "the activity is not responding?"
Because something in your application -- the activity, the service, etc. -- is tying up the main application thread.
Inside my Service i start 2 threads in order to make some tasks. can be this the cause of the problem?
Not directly, no, though you really should consider using AsyncTask
rather than forking your own threads
Doing long-running work on the main application thread, or tying it up with a sleep()
or busy-loop, will cause this exception.
这篇关于Android的服务,使活动没有响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!