服务内的线程,还是线程内的服务?
我有一个关于服务的问题:在服务中创建线程或在线程中创建服务哪个更好?
问题的出现是因为我正在为我的应用程序实现一个错误报告器,这样当应用程序失败时,它会向我发送一份包含所发生情况的报告。我的想法是,当发生错误时,从此处显示活动 Activity 发出通知,并创建一个线程来重试传递,直到成功或达到最小尝试次数。
重新提出问题,系统如何最不可能删除我的进程(如果内存不足):使用服务中的线程,还是线程中的服务?
我认为最好的就是第一选择,但是我在同一个android人中看到了一段代码,在这里:(
第640行) 来自 google 的代码保持线程活动?
他们使用第二个的地方。你对此有何看法?
我不需要 AsyncTask,因为我不需要与 UI 线程交互,此时我不会向用户显示任何内容。
I have a question about services: What would be better, create a thread within a service, or service within a thread?
The question comes because I am implementing an error reporter for my application, so that when the application fails it sends me a report with what has happened. My idea is a notification when an error occurs from here show activity Activity and creates a thread to retry delivery until it succeeds or reaches a minimum number of attempts.
Remaking the question, how is the system least likely to remove my process (if out of memory): With a thread within a service, or service within a thread?
I think the best is the first choice, but I saw a code in the same android people, here:
(line 640)
code from google to keep alive a thread??
Where they use the second. What do you think about it?
I don't need an AsyncTask, because I don't need to interact with the UI thread, I'm not showing anything at this point to the user.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在服务中创建工作线程。
Create your worker thread inside the service.