title: Unlock the Screen Programmatically
body: <p>I have a share button in the <code>GCM notification</code>. On click of the share button, I need to launch share intent. Everything works perfectly. Only problem that I'm facing is <code>Lollipop</code> lock screen feature. When I click share button from lock screen, my intent dialog appears below the lock screen and user has to unlock the screen to see the dialog. I want to unlock the screen programatically, when share button is clicked. </p>
  
  <p>I tried with Power Manager, But all it's <code>wakeClock</code> flags are deprecated and <code>WindowManager.LayoutParams.Flag_KEEP_SCREEN_ON</code>is recommened to use.  But I'm not using activity here. I'm using <code>broadcastReciever context</code>. and hence I cannot use <code>getWindow()</code>method.</p>
  
  <p>I also tried with <code>KeyguardManager</code>. But even <code>disableKeyguard()</code> is deprectated.</p>
  
  <p>I cannot use the <code>Intent.ACTION_SCREEN_ON</code>, as this should be used, if we want to perform any action after screen is unlocked.</p>
  
  <p>i had used below intent to programmatically close the notification tray:</p>
  
  <pre><code>Intent it = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
          mContext.sendBroadcast(it);
  </code></pre>
  
  <p>Is there a similar intent, that can be broadcasted to unlock the screen</p>
  
  <p><strong>Updated Code using DevicePolicyManager:</strong></p>
  
  <pre><code>public static void handleShareBtnClick(Context context, String message) {
      GcmHelper helper = new GcmHelper();
      helper.shareMessage(context, message);
      if(Utility.isLollypopAndAbove()){
            helper.unlockLockScreen();
      }
      helper.launchShareforForAlert();
  
  }
  
  
  
     public void unlockLockScreen(){
          DevicePolicyManager devicePolicyMngr= (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
          ComponentName compName=new ComponentName(mContext, DeviceAdminReceiver.class);
          if(!devicePolicyMngr.isAdminActive(compName))
              devicePolicyMngr.removeActiveAdmin(compName);
      }
  </code></pre>
  
  <p>Even after using DevicePolicyManager, It's not unlocking my screen</p>