title: PendingIntent does not send Intent extras
body: <p>My <code>MainActicity</code>  starts <code>RefreshService</code> with a <code>Intent</code> which has a <code>boolean</code> extra called <code>isNextWeek</code>.</p>
  
  <p>My <code>RefreshService</code> makes a <code>Notification</code> which starts my <code>MainActivity</code> when the user clicks on it.</p>
  
  <p>this looks like this:</p>
  
  <pre><code>    Log.d("Refresh", "RefreshService got: isNextWeek: " + String.valueOf(isNextWeek));
  
      Intent notificationIntent = new Intent(this, MainActivity.class);
      notificationIntent.putExtra(MainActivity.IS_NEXT_WEEK, isNextWeek);
  
      Log.d("Refresh", "RefreshService put in Intent: isNextWeek: " + String.valueOf(notificationIntent.getBooleanExtra(MainActivity.IS_NEXT_WEEK,false)));
      pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, 0);
  
      builder = new NotificationCompat.Builder(this).setContentTitle("Title").setContentText("ContentText").setSmallIcon(R.drawable.ic_notification).setContentIntent(pendingIntent);
      notification = builder.build();
      // Hide the notification after its selected
      notification.flags |= Notification.FLAG_AUTO_CANCEL;
      notificationManager.notify(NOTIFICATION_REFRESH, notification);
  </code></pre>
  
  <p>As you can see the <code>notificationIntent</code> should have the <code>boolean</code>extra <code>IS_NEXT_WEEK</code> with the value of <code>isNextWeek</code> which is put in the <code>PendingIntent</code>.</p>
  
  <p>When I click now this <code>Notification</code> I always get <code>false</code> as value of <code>isNextWeek</code></p>
  
  <p>This is the way I get the value in the <code>MainActivity</code>:</p>
  
  <pre class="lang-js prettyprint-override"><code>    isNextWeek = getIntent().getBooleanExtra(IS_NEXT_WEEK, false);
  </code></pre>
  
  <p>Log:</p>
  
  <pre><code>08-04 00:19:32.500  13367-13367/de.MayerhoferSimon.Vertretungsplan D/Refresh: MainActivity sent: isNextWeek: true
  08-04 00:19:32.510  13367-13573/de.MayerhoferSimon.Vertretungsplan D/Refresh: RefreshService got: isNextWeek: true
  08-04 00:19:32.510  13367-13573/de.MayerhoferSimon.Vertretungsplan D/Refresh: RefreshService put in Intent: isNextWeek: true
  08-04 00:19:41.990  13367-13367/de.MayerhoferSimon.Vertretungsplan D/Refresh: MainActivity.onCreate got: isNextWeek: false
  </code></pre>
  
  <p>When I directly start the <code>MainActivity</code> with an <code>Intent</code> with the ìsNextValue` like this:</p>
  
  <pre><code>    Intent i = new Intent(this, MainActivity.class);
      i.putExtra(IS_NEXT_WEEK, isNextWeek);
      finish();
      startActivity(i);
  </code></pre>
  
  <p>everything works fine and I get <code>true</code> when <code>isNextWeek</code> is <code>true</code>.</p>
  
  <p>What do I make wrong that there is always a <code>false</code> value?</p>
  
  <h1>UPDATE</h1>
  
  <p>this solves the problem:
  <a href="https://stackoverflow.com/a/18049676/2180161">https://stackoverflow.com/a/18049676/2180161</a></p>
  
  <p><em>Quote:</em></p>
  
  <blockquote>
    <p>My suspicion is that, since the only thing changing in the Intent is
    the extras, the <code>PendingIntent.getActivity(...)</code> factory method is
    simply re-using the old intent as an optimization.</p>
    
    <p>In RefreshService, try:</p>
  
  <pre><code>PendingIntent pendingIntent = PendingIntent.getActivity(this, 0, notificationIntent, PendingIntent.FLAG_CANCEL_CURRENT);
  </code></pre>
    
    <p>See:</p>
    
    <p><a href="http://developer.android.com/reference/android/app/PendingIntent.html#FLAG_CANCEL_CURRENT" rel="noreferrer">http://developer.android.com/reference/android/app/PendingIntent.html#FLAG_CANCEL_CURRENT</a></p>
  </blockquote>
  
  <h1>UPDATE 2</h1>
  
  <p>See <a href="https://stackoverflow.com/a/37695826/2180161">answer below</a> why it is better to use <code>PendingIntent.FLAG_UPDATE_CURRENT</code>.</p>