title: How can I keep my Android service running when the screen is turned off?
body: <p>When the screen turns off, my application service is paused.</p>
  
  <p>I start my service with the following code:</p>
  
  <pre><code>if (mSharedPrefs.getBoolean("prefAutoUpdatesMain", false)) {
       Intent svc = new Intent(this, MyService.class);
       startService(svc);
  }
  </code></pre>
  
  <p>How can I can avoid the service pause?</p>
  
  <hr>
  
  <p>What I have to do in MyService is to download some data from Internet. If I have understand the process I have to follow is:</p>
  
  <ol>
  <li>Acquire wakeLock</li>
  <li>Download data</li>
  <li>Release wakeLock</li>
  </ol>
  
  <p>In downloading data method there are no reference to wakeLock, it is the application to have the wakeLock, is it correct?</p>
  
  <p>Wake locks are reference counted by default. I think it is better a wakeLock without reference counting, to be sure to release it, am I wrong?</p>