title: Android how to launch activity when ever phone unlock?
body: <p>I want to start my application whenever the phone is unlocked.</p>
  
  <p>Below is my code which works fine when the phone is restarted, but I also want it to work whenever the phone is unlocked. </p>
  
  <p>What should I do?</p>
  
  <p>I want to start my application every time the user unlocks the phone. What did I do wrong in my code?</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="utf-8"?&gt;
    &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
           package="com.example.installedapps22"
           android:versionCode="1"
           android:versionName="1.0" &gt;
  
   &lt;uses-sdk
      android:minSdkVersion="8"
      android:targetSdkVersion="16" /&gt;
  
  
   &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/&gt;
  
   &lt;application android:icon="@drawable/cherry_icon" android:label="@string/app_name"&gt;
      &lt;activity android:name=".MainActivity"
                android:label="@string/app_name"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="android.intent.action.MAIN" /&gt;
              &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/activity&gt;
  
  
     &lt;receiver android:name=".BootUpReciever"   android:enabled="true" 
      android:exported="true"&gt;
  
   &lt;intent-filter&gt;
      &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
      &lt;action android:name="android.intent.action.SCREEN_OFF" /&gt;
      &lt;action android:name="android.intent.action.SCREEN_ON" /&gt;                    
      &lt;category android:name="android.intent.category.DEFAULT" /&gt;
   &lt;/intent-filter&gt;
  
      &lt;/receiver&gt;  
  
  
  
  
  
  
    &lt;activity android:name=".ListInstalledApps" &gt; &lt;/activity&gt; 
  
  
   &lt;activity android:name=".TabsLayoutActivity" /&gt;
    &lt;/application&gt;
  
   &lt;/manifest&gt;
  
  
   public class BootUpReciever extends BroadcastReceiver {  
  
      @Override  
      public void onReceive(Context context, Intent intent) {
          System.out.println("in broad....");
  
          if ((intent.getAction() != null) &amp;&amp;  
               (intent.getAction().equals("android.intent.action.BOOT_COMPLETED")))
          {
  
          System.out.println("in broadcast receiver.....");
          Intent i = new Intent(context, MainActivity.class);  
          i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
          context.startActivity(i);  
   }
  
   else if (intent.getAction().equals(Intent.ACTION_SCREEN_ON)) {
  
       Intent i = new Intent(context, MainActivity.class);  
       i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); 
       context.startActivity(i);
   } 
  
    }
  
  }
  </code></pre>