BroadcastReceiver的的onReceive超时 [英] BroadcastReceiver onReceive timeout

查看:1369
本文介绍了BroadcastReceiver的的onReceive超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对的BroadcastReceiver ,而在的onReceive()我做我需要做的。

I extend BroadcastReceiver, and in onReceive() I do whatever I need to do.

的onReceive()有一个超时,从文档:

onReceive() has a timeout, from the documentation:

有10秒的超时那   该系统允许后再考虑   接收机要阻挡和   候选人被杀害

there is a timeout of 10 seconds that the system allows before considering the receiver to be blocked and a candidate to be killed

这将创建一个问题,当我在调试模式。我需要10秒以上(有时)。如果我不这样做我所有的调试在10秒内我会关闭连接并调试停止。

This creates a problem when I am in debug mode. I need more than 10 seconds (sometimes). If I don't do all my debugging in 10 seconds my connection is closed and debugging is stopped.

我可以增加超时或禁用调试目的?

Can I increase the timeout or disable it for debugging purposes?

感谢。

推荐答案

在为prevent从力收你的应用程序,而你是暂停在调试过程中一个破发点,尝试安装在开发工具的应用并启用的调试应用程序设置它:

In order to prevent your app from force closing while you are paused on a break point during debugging, try installing the Dev Tools application and enable the Debug App setting which:

让您选择应用程序   调试。你并不需要将其设置为   附加一个调试器,但是设置这个   价值有两个作用:

Lets you select the application to debug. You do not need to set this to attach a debugger, but setting this value has two effects:

      
  • 将prevent的Andr​​oid从抛出一个错误,如果你停留在   断点很长一段时间,而   调试。
  •   
  • It will prevent Android from throwing an error if you pause on a breakpoint for a long time while debugging.

所有的细节在这里: http://developer.android.com /tool​​s/debugging/debugging-devtools.html

如果你正在做的事情在你的的onReceive 的方法,然后再考虑让你的的BroadcastReceiver 开始的服务并传递下去它在的onReceive <获取数据/ code>。那么服务可以做再处理。

If you are doing something complicated in your onReceive method, then consider having your BroadcastReceiver start a Service and pass along the data it gets from within onReceive. The Service can then do the longer processing.

这篇关于BroadcastReceiver的的onReceive超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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