I have an Activity that will query a RESTful API every x seconds (polls using a handler). The results of the GET are used to update a ListView. This is done using an AsyncTask.
I want to put a Notification in the Notification bar when certain criteria are met in the new data. Everything I have read up to this point has suggested that notifications should be created and updated using a service so that the notifications can be made even when the application isn't in focus. I see the positive aspects of this.
However, I'm unsure if I should just create a service from within my activity or if I need to do something more complex than that. I'm undecided on if I should scrap my AsyncTask model in favor of using the Service to update my list view.
So, my questions are:
1) Is there a good tutorial showing how to make a local service from an activity?
The tutorial doesn't need to show how to make them communicate, the service could be isolated from the main activity.
2) Will #1 provide me with the notification benefits I'm looking for? (Notifications are generated even when the main app isn't visible)
3) Should I use this same service to update my listview?
The service would basically be making the same query that the AsyncTasks are, just doing different things with the results. The app would seem to make more sense to have the Service query, do notification processing, then give the results to the activity, but I haven't found a good resource that clearly demonstrates how to do something like this.
I can add any necessary code or explain further if need be.