title: Wake the device up when app prompts user
body: <p>I'm using handler to repeatedly prompt user for an input every e.g. 5 minutes. When the device goes into sleeping mode and screen is locked, how can I wake the device up when my app prompts user for input? I've tried this but it doesn't seem to work. I've added <code>WAKE_LOCK</code>permission in the manifest.</p>
  
  <pre><code>class BtHandler extends Handler {
      private PowerManager pm;
      private WakeLock wl;
  
      @Override
      public void handleMessage(Message msg) {
          pm = (PowerManager)FixedNode.this.getSystemService(Context.POWER_SERVICE);
          if (!pm.isScreenOn()) {
              wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK, "TAG");
              wl.acquire();
          }
          FixedNode.this.setAlwaysDiscoverable();
          wl.release();
      }
  }
  </code></pre>
  
  <p>Any ideas?</p>
  
  <p>Edit: Using <code>AlarmManager</code>to broadcast custom intent.</p>
  
  <pre><code>mReceiver = new BroadcastReceiver() {
  
      @Override
      public void onReceive(Context context, Intent intent) {
          Vibrator v = (Vibrator) getSystemService(Context.VIBRATOR_SERVICE);
          v.vibrate(300);
          PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);
          KeyguardManager km = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
          WakeLock wl = null;
  
          if (!pm.isScreenOn()) {
              KeyguardLock kl = km.newKeyguardLock("TAG");
              kl.disableKeyguard();
              wl = pm.newWakeLock(
                  PowerManager.SCREEN_BRIGHT_WAKE_LOCK | 
                  PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
              wl.acquire();
          }
  
          Toast.makeText(context, "Alarm worked", Toast.LENGTH_LONG).show();
          wl.release();
      }
  };
  
  mFilter = new IntentFilter(ACTION_NAME);
  
  Intent mIntent = new Intent(ACTION_NAME);        
  PendingIntent pendingIntent = PendingIntent.getBroadcast(this, 0, mIntent, 0);
  AlarmManager am = (AlarmManager) getSystemService(ALARM_SERVICE);
  am.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + (120 * 1000), pendingIntent);
  Toast.makeText(this, "Alarm set", Toast.LENGTH_LONG).show();
  </code></pre>