title: Detecting when screen is locked
body: <p>I've seen a couple of posts on here on how to check if the screen is locked, but none of it has been working for me. It all detects if the actual screen is off or not (not if it's locked).</p>
  
  <p>I have a game in which music plays. When the lock button is pressed, it continues to play. I originally had the music stopping in <code>OnStop</code>, but the application would restart after getting locked, so the music would eventually start up again.</p>
  
  <p>Then, I added <code>KeyboardHidden|orientation</code> to the manifest. This makes it so it doesn't restart the app, but <code>OnStop</code> doesn't seem to get called anymore.</p>
  
  <p>I've tried using <code>PowerManager</code> to see if the screen is on/off, which works, but doesn't help. (I can get the music to stop there, but as soon as you hit the lock button again, the music starts right back up)</p>