开发者

Thread inside a service, or service inside a thread?

开发者 https://www.devze.com 2023-02-19 07:02 出处:网络
I have a question about services: What would be better, create a thread within a service, or service within a thread?

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 se开发者_如何学JAVArvice, 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.


Create your worker thread inside the service.

0

精彩评论

暂无评论...
验证码 换一张
取 消