title: How to ask user to unlock device on clicking notification action in android?
body: <p><br/>
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I am displaying a notification from my application and this notification has an action in it, when user clicks on the action, the corresponding action class is called with the intent I set. Now, I want to perform a particular action but before that the user needs to unlock the screen if it is pin/pattern protected. I am not able to ask user to unlock device, i.e open up the unlock keypad/pattern on lock screen.
  <br/>
  Below is the code I have,</p>
  
  <pre><code>    //HandleAction is a java class that extends IntentService
      Intent intent = new Intent(context, HandleAction.class);
      intent.putExtra(key, "my_value"); //Used to send information to action class
      PendingIntent pi = PendingIntent.getService(context, 0, intent,
                                   PendingIntent.FLAG_UPDATE_CURRENT);
  
      NotificationCompat.Builder notification = new NotificationCompat.Builder(mContext);
      //set the title, icon etc for builder and add action as below
      notification.addAction(icon, "my_label", pi);
  </code></pre>
  
  <p>When user clicks on the notification action, I get the control to onHandleIntent in MyAction.java <br/>
  In here, I want to request user to unlock device if password protected and then perform an action.
  How can I request user to unlock device in onHandleIntent?</p>
  
  <p>I came across using KeyguardManager and KeyguardLock to acheive this but keyguardManager.newKeyguardLock is deprecated method and I want to avoid this. So, the next was using "FLAG_TURN_SCREEN_ON" and "FLAG_KEEP_SCREEN_ON" but I am unable to figure out how to use them in this context. I don't launch any window from my action class, it is just an operation like incrementing my counter. After clicking it the notification should disappear, perform my action and thats it.</p>
  
  <p>I found a similar question <a href="https://stackoverflow.com/questions/34179195/how-to-ask-user-to-unlock-phone">Unlock phone</a> , but the way it was did is by launching a dummy/empty activity. </p>
  
  <p>Thanks in advance for any help, suggestions :)</p>