Android Foreground Service Help [closed]
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this questionI'm working on an application that requires I run a long process in the foreground (mostly download开发者_JS百科ing a few large files), however, after much searching, and googling I have been unable to turn up a tutorial or example on foreground services. I've never used a foreground service so I'm a bit lost at the moment. Could anyone lend a hand on basic foreground services, maybe some sample code on starting one and ending one?
Thank you
An example is given in the developer guide over here.
You should be using an AsyncTask if it's running in the foreground.
With an AsyncTask you can run things in the UI on progress updated with activity.runOnUiThread(new Runnable())
Give this a try, see if it is what you're looking for :)
Hope this helped.
精彩评论