title: Stop the Service on Destroy of Application
body: <p>I am confused right now , about service concept of running and stopping:</p>
  
  <p>what i want to do:</p>
  
  <ul>
  <li><p>Start Location service at the very start of application.</p></li>
  <li><p>Keep getting location updates and <strong>store</strong> them to shared preference</p></li>
  <li><p>Stop the service in <strong>onDestroy of Application scope!</strong></p></li>
  </ul>
  
  <p>So far i have searched and studied we can only do following things with service(correct me if i'm wrong):</p>
  
  <ul>
  <li><p>Stop the service automatically by binding it to related activities/fragments/views , when all of them destroyed service unbind itself automatically so we can call <code>stopself</code> method in unbind</p></li>
  <li><p>return START_NOT_STICKY in onStartCommand to tell OS , don't recreate it , and create  intent local service , after completion of some work it will destroy itself.</p></li>
  <li><p>Stopping the service manually , by declaring it's intent in some kind of static scope and stopping the service in on <code>onActivityDestroyed</code> of Application class [I am not sure what will happen? , maybe service will destroy each time any activity will be destroyed ? or it will be destroyed only when overall application get's destroyed?]</p></li>
  </ul>
  
  <p>Either way , i am bit confused and beat , been trying to adjust my <code>Location service</code> with given details for 2 days</p>