Pass download service work may IntentServicepossibly WakefulIntentService, depending on whether there is a risk that the device could fall asleep during the work itself.
Yours AppWidgetProviderwill just call startService()on yours IntentService.
Your method IntentService's onHandleIntent()will do the work you are currently using in onUpdate(), getting your own AppWidgetManagerusing the static method getInstance(). But, since it onHandleIntent()runs in the background thread, you can take as much time as you need. IntentServicewill also turn off automatically as soon as this is done with all outstanding work requests.
source
share