title: Launch application when device turn on or unlocked
body: <p>1.How to launch/open application when the device is just open?</p>
  
  <p>2.How to launch/open application when the device is just unlocked/exit from lock state?</p>
  
  <p>(I mean, how to recognize these events?)</p>
  
  <p>10q,</p>
  
  <p>David</p>
  
  <p>This is my new code:</p>
  
  <p>In Manifest:</p>
  
  <pre><code>&lt;receiver
    android-permission="android.permission.RECEIVE_BOOT_COMPLETED"
    android:name="BootReciver" &gt;
    &lt;intent-filter &gt;
        &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
        &lt;action android:name="android.intent.action.SCREEN_ON" /&gt;
    &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  </code></pre>
  
  <p>In BootReciver.java I added to my project:</p>
  
  <pre><code>package development.Grandpa;
  import android.content.BroadcastReceiver;
  
      public class BootReciver extends BroadcastReceiver {
      public void onReceive(Context context, Intent intent) {
          Intent intent1 = new Intent(context, Grandpa.class);
          context.startActivity(intent1);      
      }
  }
  </code></pre>
  
  <p>Where Grandpa class is my Main Activity.</p>
  
  <p>In addition, I'm running the code directlly on my device and that is what I'm getting in the LogCat:</p>
  
  <p>??-?? ??:??:??.???: INFO/(): Unable to open log device '/dev/log/main': No such file or directory</p>
  
  <p>I also tried to add one reciver for boot and another one for ScreenOn (with two classes) like this:</p>
  
  <pre><code>&lt;receiver
  android:name="ScreenOnReciver" &gt;
      &lt;intent-filter &gt;
      &lt;action android:name="android.intent.action.SCREEN_ON" /&gt;
  &lt;/intent-filter&gt;
  &lt;/receiver&gt;
  
  &lt;receiver
  android-permission="android.permission.RECEIVE_BOOT_COMPLETED"
  android:name="BootReciver" &gt;
  &lt;intent-filter &gt;
      &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
  &lt;/intent-filter&gt;
   &lt;/receiver&gt;
  </code></pre>
  
  <p>But it didn't help also.</p>
  
  <p>Edit:</p>
  
  <p>This it what I'm getting in logcat after:</p>
  
  <p>1.Run the application</p>
  
  <p>2.Exit from the application</p>
  
  <p>3.Lock Screen</p>
  
  <p>4.Unlock Screen</p>
  
  <pre><code>11-13 23:59:26.140: ERROR/AndroidRuntime(3640): Set to default setting_6 : region=-   Duser.region=IL propRegn=IL
  11-13 23:59:26.710: ERROR/AndroidRuntime(3649): Set to default setting_6 : region=-Duser.region=IL propRegn=IL
  11-13 23:59:33.246: ERROR/power(244): *** set_screen_state 0
  11-13 23:59:33.246: ERROR/SensorManager(244): unregisterListener:: all sensors,    listener = com.android.server.PowerManagerService$13@40517118
  11-13 23:59:33.593: ERROR/LockPatternKeyguardView(244): Phone is boot completed. so can   send broadcast message for music player
  11-13 23:59:35.286: ERROR/power(244): *** set_screen_state 1
  11-13 23:59:35.286: ERROR/SensorManager(244): registerListener :: handle = 3  name=     GP2A Light Sensor delay= 200000 Listener=   com.android.server.PowerManagerService$13@40517118
  11-13 23:59:35.286: ERROR/SensorManager(244): reg :: handle = 3
  11-13 23:59:35.336: ERROR/LockPatternKeyguardView(244): Phone is boot completed. so can  send broadcast message for music player
  11-13 23:59:36.360: ERROR/SlidingTab(244): onTouchEvent() : thresholdReached !
  11-13 23:59:36.380: ERROR/KeyguardViewMediator(244): Phone is boot completed. so can   broadcast
  11-13 23:59:36.400: ERROR/MTPRx(3319): In MtpReceiverandroid.intent.action.USER_PRESENT
  11-13 23:59:36.410: ERROR/MTPRX(3319): Battery charging. plugType = 2
  11-13 23:59:36.410: ERROR/MTPRx(3319): USB charging
  11-13 23:59:36.416: ERROR/MTPRx(3319): usb is connected, set value in Settings.System,   result = true
  11-13 23:59:36.416: ERROR/MTPRx(3319): usb mode = 0
  11-13 23:59:36.416: ERROR/MTPRx(3319): usb debugging is enabled
  </code></pre>
  
  <p>Edit2: </p>
  
  <p>I have only these "Exception" in the logcat:</p>
  
  <pre><code>11-14 00:22:15.313: WARN/WindowManager(244): android.view.InflateException: Binary XML  file line #7: Error inflating class &lt;unknown&gt;
  11-14 00:22:15.313: WARN/WindowManager(244): Caused by: java.lang.reflect.InvocationTargetException
  11-14 00:22:15.313: WARN/WindowManager(244): Caused by:   android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or   path): TypedValue{t=0x2/d=0x1010059 a=-1}
  </code></pre>