Execute long running operations on the service

前端 未结 2 1889
失恋的感觉
失恋的感觉 2020-12-21 12:54

I\'m building an application which have a Service. I know that all application components run in the same UI process, at least you specify it in the manifest. So to avoid AN

相关标签:
2条回答
  • 2020-12-21 13:13

    First of all, let's accept that there 2 parts: an active part (the networking) and some sleeping part before the next active part. I think you can use a plain local IntentService for active parts. Each active part on its completion should reschedule the next active part using AlarmManager. This approach makes sure your app does not consume resources during sleeping parts. You are right - once the IntentService gets a result to be presented to user it can use Notification.

    0 讨论(0)
  • 2020-12-21 13:26

    Android Service executing in UI thread. So you should use AsyncTask or another way to work with threads for network requests.

    0 讨论(0)
提交回复
热议问题