title: Proper way to Android update service
body: <p>I am currently developing Android application with webservice synchronization and everything is working smoothly, but I need to create a background Update service, for data fetching to database. Last couple days, I've been searching for information how to accomplish this and I found many solution, which confused me pretty badly.</p>
  
  <p>I am fetching data using asyncTask which fire up the httpClient and the I parse response and save it to database. After that I send an intent to launch an Activity. Simple stuff.</p>
  
  <p>I want a service, which would fetch the data while the application isn't running. And probably stop the service, when user start the application.</p>
  
  <p>I manage to write a Service class with thread sleep, but this seems like a pretty bad solution. </p>
  
  <p>Another solution I found, is by using pendingIntent and broadcast receivers. </p>
  
  <p>I am not sure if sending broadcast intent is a secure enough. If someone plug his phone into a debugger, he would see every intent broadcast, right? Which means he/she could mess with my application (like send an broadcast intent, which would inform application that new data has been fetch, when in reality, that would not be the case).</p>
  
  <p>I also don't want to getting my service killed by system.</p>
  
  <p>Is there any simple and effective solution for this? I kinda struggle to find something suited for me needs and I am pretty new to Android programing to write it by myself. I found many solution, but I really don't know which one is "right" solution, which is the most effective.</p>