螺纹螺纹内的服务,或者服务内? [英] Thread inside a service, or service inside a thread?

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

问题描述

我有一个关于服务问题:是什么更好的,创建一个线程内的服务中的一个线程,或服务

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?

我觉得最好的是第一选择,但我看到了一个code在同一个Android的人,在这里:

I think the best is the first choice, but I saw a code in the same android people, here:

(线640)
<一href=\"http://android.git.kernel.org/?p=platform/packages/apps/Contacts.git;a=blob;f=src/com/android/contacts/ui/EditContactActivity.java;h=3e248ea93dc8b17a0d66306aaade9ea398c32408;hb=HEAD\"相对=nofollow>从谷歌code养活一个线程??

如果他们使用的第二位。你对此怎么看?

Where they use the second. What do you think about it?

我不需要一个AsyncTask的,因为我并不需要与UI线程交互,我没有显示在这一点上给用户任何东西。

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.

推荐答案

创建服务中的工作线程。

Create your worker thread inside the service.

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

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