Android – get the progress of intentservice

I'm developing an Android application that requires a lot of API calls. I've built a system to implement a queuing system based on intentservice. The problem is, I want to display accurate ProgressBar updates when intentservice runs

One way is to change the queuing system to a series of asynctasks. I have to use onprogressupdate() to display the progress

Another method is to adjust the intentservice and get the progress from the background thread

The problem is, I want to combine the advantages of intentservice and asynctask: make a queuing system that can easily handle UI events. Is there the best way to implement it?

Editor: I end up using asynctasks instead of intentservices. However, if anyone has a good model to share to update progress from intentservice, please feel free to add your comments

resolvent:

ID

>Start handlerthread and handler > get handler of main UI thread > publish work to background thread using handler of this thread > publish progress updates and results to UI using handler of UI thread

This way, you can have a background thread to process your work queue and publish anything you like back to the UI thread without processing the broadcast

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>