title: BroadcastReceiver's behaviour for ACTION_SHUTDOWN
body: <p>I have <code>BroadcastReceiver</code> which listens for <code>ACTION_SHUTDOWN</code> and some other actions.  </p>
  
  <p>My problem is, when I shutdown my android device(2.3.6) <code>BroadcastReceiver</code> is catching <code>ACTION_SHUTDOWN</code> two times. Problem is only with <code>ACTION_SHUTDOWN</code> and not with other actions.  </p>
  
  <p>When I run same code on emulator, it works fine.<br>
  Guys please help me. Here is my code:</p>
  
  <p>my <code>BootReceiver.java</code></p>
  
  <pre><code>public class BootReceiver extends BroadcastReceiver {
  
      @Override
      public void onReceive(Context context, Intent intent) {
  
           if(Intent.ACTION_SHUTDOWN.equalsIgnoreCase(intent.getAction())) {
                 Log.i("Boot Receiver - Shutdown event");
                 // database operation
           }
  
           if(Intent.ACTION_BOOT_COMPLETED.equalsIgnoreCase(intent.getAction())) {
                 // some operation
           }
  
           if(Intent.ACTION_AIRPLANE_MODE_CHANGED
                                 .equalsIgnoreCase(intent.getAction().intern())) {
                 // some operation
           }
  
           if(ConnectivityManager.CONNECTIVITY_ACTION
                                          .equalsIgnoreCase(intent.getAction())) {
                 // some operation
           }
       }
  }
  </code></pre>
  
  <p><code>AndroidManifest.xml</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.xyz.ui"
  android:versionCode="1"
  android:versionName="1.0" &gt;
  
  &lt;uses-sdk
      android:minSdkVersion="10"
      android:targetSdkVersion="17" /&gt;
  
  &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  &lt;uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/&gt;
  &lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.CHANGE_NETWORK_STATE"/&gt;
  
  &lt;application
      android:allowBackup="true"
      android:icon="@drawable/spota"
      android:label="@string/app_name"
      android:theme="@style/AppTheme" 
      &gt;
      &lt;activity
          android:name="com.xyz.UserActivity"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"&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="com.xyz.BootReceiver"&gt;
           &lt;intent-filter &gt;
               &lt;action android:name="android.intent.action.BOOT_COMPLETED" /&gt;
               &lt;action android:name="android.intent.action.ACTION_SHUTDOWN" /&gt;
               &lt;action android:name="android.net.conn.CONNECTIVITY_CHANGE" /&gt;
               &lt;action android:name="android.intent.action.BATTERY_CHANGED" /&gt;
               &lt;action android:name="android.intent.action.AIRPLANE_MODE"/&gt;
           &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  
  &lt;/application&gt;
  </code></pre>
  
  <p></p>
  
  <p>And here is the <code>Logcat</code> entries</p>
  
  <pre><code>05-03 16:37:23.826: I/xyz(2337): Boot Receiver - Shutdown event
  05-03 16:37:23.881: I/xyz(2337): Inserting Data
  05-03 16:37:28.514: I/xyz(2337): Boot Receiver - Shutdown event
  05-03 16:37:28.529: I/xyz(2337): Inserting Data
  </code></pre>
  
  <p>Thanks!</p>