title: Prevent my device to turn off when my device is locked
body: <p>I stuck in little tricky logic. I want to prevent my device to turn off when my device is locked. I am just making an app for antitheft but here is problem that my logic is not working in Pie devices. </p>
  
  <p>That's means after lots of searching on stack overflow. and try lots of code I am still unable to detect of my power key. I tried <code>KEYCODE EVENT</code> but it was use less. </p>
  
  <p><code>After lots of try from two months Now I am forget that How many answered I have been tried.</code>  </p>
  
  <p>Hope fully all of you guys will help me to solve my problem.</p>
  
  <p><strong>Main Problem</strong></p>
  
  <p><strong><code>How can I prevent my device to turn off when my device is locked. 
  (Specially Pie Devices and above)</code></strong></p>
  
  <p>You can consider my problem as  </p>
  
  <blockquote>
    <p><strong>I want to disable my device my Power button Long press function when my device is locked</strong></p>
  </blockquote>
  
  <p>You can also consider my problem as  </p>
  
  <blockquote>
    <p><strong>Override on Power button when my device is locked</strong></p>
  </blockquote>