title: How to detect lock and unlock of screen pinning on android
body: <p>I am working on an android app that should be used by students in some kind of practical test.
  I am using the screen pinning that was introduced in Lollipop (<strong>startLockTask()</strong>), so when my app is launched the user needs to allow the locking.</p>
  
  <p><strong>I couldn't find a way to know <em>when</em></strong> the user click ok for the locking and when he unlock the pinning? (The user can cancel the lock by holding both the Back and Recent buttons).
  I am not looking for a way to know if the user <strong>currently in lock screen</strong> (getLockTaskModeState ()), i want to know if i have a way to <strong>handle the events</strong> of locking or unlocking.</p>
  
  <p>I want that in the begining of the test i will be able to send information to my server if the users 'logged in' properly (by allowing the lock), and as well if the user unlock the device before the end of the test. </p>
  
  <p><strong>EDIT</strong></p>
  
  <p>Hey, people!
  Please explain yourselves after downvoting!
  If I wasn't exaplaining myself - i will try again if you will let me know.
  I read a lot of questions and answers about general lock screen, but not the one of app pinning, I also read about check the status of the current task- if it is locked or not, but i didn't find answer to what i am asking - is there a way to handle the event of unlocking the 'screen pinning' of a specific app.
  So please, explain your downvotes!</p>