title: ApplicationContext in BroadcastReceiver
body: <p>I have an Application class like this: </p>
  
  <pre><code>public class MyApplication extends Application {
  }
  </code></pre>
  
  <p>It is registered in the Manifest: </p>
  
  <pre><code>    &lt;application
          android:name=".MyApplication"
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
      ... 
  
      &lt;/application&gt;
  </code></pre>
  
  <p>I use this Application class for keeping Dagger components etc. </p>
  
  <p>Now I have a BroadcastReceiver: </p>
  
  <pre><code>public class MyBroadcastReceiver extends BroadcastReceiver {
      @Override
      public void onReceive(final Context context, final Intent intent){
  
         MyApplication myApplication = (MyApplication) context.getApplicationContext();           
      }
  }
  </code></pre>
  
  <p>It is registered in the Manifest as a <a href="https://developers.google.com/android/reference/com/google/android/gms/tagmanager/InstallReferrerReceiver" rel="nofollow noreferrer">InstallReferrerReceiver</a>: </p>
  
  <pre><code>    &lt;receiver
          android:name="my.package.MyReceiver"
          android:exported="true"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.android.vending.INSTALL_REFERRER"/&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;
  </code></pre>
  
  <p>As you can see I cast the application context to my Application class, which works fine in Activities etc. and also usually here. </p>
  
  <p>Via Crashlytics though I receive exception: </p>
  
  <pre><code>Unable to start receiver my.package.BroadcastReceiver: java.lang.ClassCastException: android.app.Application cannot be cast to my.package.MyApplication
  </code></pre>
  
  <p>My question being: am I <em>not</em> guaranteed to receive my Application object as the application Context in a BroadcastReceiver?</p>