Android的服务,使活动没有响应Android

由网友(你送的玫瑰×)分享简介:任何人都知道,可当我从活动启动服务的原​​因,仿真器显示消息活动不响应?在我的服务,我开始2个线程,以便使一些任务。可能是这个问题的原因是什么?感谢解决方案 任何人知道什么可能是原因当我从开始服务活动中,仿真器显示消息活动不响应?由于东西在你的应用程序 - 活动,服务等 - 被占用主应用程序线程在我的服务,我开始2线...

任何人都知道,可当我从活动启动服务的原​​因,仿真器显示消息活动不响应?

在我的服务,我开始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?"

iOS 平板与 Android 平板的交互与动画

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.

阅读全文

相关推荐

最新文章