title: Add a device auth before shutting down the device without unlock
body: <p>Hey guys I have an app that has an antitheft feature called <code>AnitPowerOff</code>, this feature needs to stop the user from shutting down the phone while in the locked state. Actually there is a CountDownTimer that times out and then the app locks the device. So I have this Samsung Galaxy A10 smartphone and it whenever I lock the screen and then try to shut down after I click the shut down button then it requires a password. Is there a way of programatically achieving this with Android Java. I have tried using a BroadcatReceiever but the app goes off and does not give the app time to execute the ode inside <code>OnReceive</code>. Here is the BroadcastReceiver attempt. I need to use a service that listens on shutdown events.</p>
  <pre><code> public class ShutdownReceiver : BroadcastReceiver
      {
         
          public override void OnReceive(Context context, Intent intent)
          {
              if (intent.Action == Intent.ActionShutdown)
              {
                  Toast.MakeText(context,&quot;Your trying to shut down the device&quot;,ToastLength.Long).Show();
                  //require some form of pattern from the device
              }
          }
      }
  </code></pre>
  <p>The code is in C# but any Java code is welcome as I can easily convert it to C# for Xamarin Android. Is there a way to start a service that will capture when the shutdown button is clicked and then before the action goes through we tell the system to require password from the user?</p>