title: Android Power Manager Wake Lock
body: <p>I've got application which is playing TV streams and needs to be ON all the time.
  I do acquire wake lock in OnCreate()</p>
  
  <pre><code>pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
  wl = pm.newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK, TAG);
  wl.acquire();
  </code></pre>
  
  <p>and then release in onDestroy()</p>
  
  <pre><code>if (wl != null) {
      wl.release();
      wl = null;
  }
  </code></pre>
  
  <p>User usually minimize the app by pressing back, home or power button
  and then resumes from home screen tapping the app icon.
  I do release wake lock in onPause() and acquire in onResume().</p>
  
  <p>Time to time I see application crashes or disappears completely from screen and I see
  logs related to wake lock.</p>
  
  <p>Is this a best practice to control Android Power Manager Wake Lock?</p>
  
  <p>Any opinions are welcome.</p>