title: How to pass context to BroadcastReceiver?
body: <p>I need to pass activity context to <code>onReceive</code> of <code>MyAlarmReceiver extends BroadcastReceiver</code> class. For that, I pass the context while setting intent:</p>
  
  <pre><code>myAlarmManager.set(AlarmManager.RTC_WAKEUP, d.getTime(),   
      PendingIntent.getBroadcast(MainActivity.this, 1,
      myIntentAlarm, PendingIntent.FLAG_ONE_SHOT));
  </code></pre>
  
  <p>However, context in <code>onReceive</code> is not the same as one passed in <code>myAlarmManager</code>. Why?</p>