title: Android: Wakelock & handling orientation change
body: <p>I'm using Wakelock in my application to prevent the phone from sleeping when the app is visible.</p>
  
  <p>The problem comes when there is an orientation change and the system destroys and re-creates the app in landscape mode. If the wakelock timer has expired in the background the system takes the release of wakelock as an opportunity to switch off the screen.</p>
  
  <p>Edit: I should mention that I am setting Wakelock onResume, and releasing onPause - as I understand it, it's necessary to release then to prevent the app from leaking the wakelock.</p>
  
  <p>I need wakelock to continue through the orientation change.</p>
  
  <p>Below I've outlined a solution to this. Is this the preferred way to handle it, and are there any alternatives?</p>
  
  <hr>
  
  <p>Create a service which holds wakelock (rather than the activity) and when the activity unbinds the service starts a countdown timer (for say 10 seconds) in which it will release wakelock when the timer expires if the activity does not rebind. If it was a simple orientation change the activity will rebind within that 10 seconds and so maintain wakelock, if it doesn't, wakelock will be released.</p>
  
  <p>Thanks.</p>