title: Launching an activity on phone unlock/startup
body: <p>I'm trying to find a way to make my app launch an activity when a phone is unlocked/turned on after X time (15 minutes for example). I've been jotting ideas down and trying to find a way with no major errors.</p>
  
  <p>I tried an IF command using</p>
  
  <pre><code>public void onReceive(Context context, Intent intent){
   KeyguardManager keyguardManager = (KeyguardManager)context.getSystemService(Context.KEYGUARD_SERVICE);
   if (!keyguardManager.isKeyguardSecure()){
    Intent startup = new Intent(MainActivity.this, NextActivity.class);}
  </code></pre>
  
  <p>But the NextActivity gets re-opened immediately whenever closed. I haven't tried the timer addition yet because I've been stuck on this part for about 2 days but any advice going into it would be appreciated. </p>
  
  <p>Also I'm going to add an If command before this command to check if the device even has a security lock, and if it doesn't the code will check to see if the screen is on, but I haven't gotten that far yet.</p>
  
  <p>Sorry If I'm not clear on what I need help on, only ever browsed this website.</p>