title: Android: Best way to fetch data from server (Widget + application)
body: <p>I'm developing an Android application where I need to fetch data (news items) from a server. I know how to do this, using threads and/or AsyncTasks, etc, but since I need the data in a widget also, and because I would like to know what way is preferred in general, I thought I'd ask you guys.</p>
  
  <p>I thought of a few specific implementations, namely;</p>
  
  <p>1) Basically create a class which uses Threads to fetch the data, which I access from both my normal Activities and the Widget. Maybe cache the information for later use.</p>
  
  <p>2) Using a Service, which I can ask for data from both my widget and application. This Service doesn't need to be running all the time, but can be started when I need the data and stops when it has fetched and returned the data. This Service can be started periodically to update the data for the Widget, or something like that.</p>
  
  <p>There are probably many ways to solve this, so I'd love to hear what you think is a good approach for this problem.</p>
  
  <p>Thanks in advance,
  Erik</p>