title: Passing data from a BroadcastReceiver to MainActivity works correctly only once
body: <p>I have a <code>PushNotificationReceiver (extends BroadcastReceiver)</code> and <code>MainActivity</code>. The receiver sends some data (for example string value "<code>New value</code>") to the <code>MainActivity</code> via an <code>Intent</code>. Then <code>MainActivity</code> updates its <code>TextView</code> with this value.
  This works fine until I change this <code>TextView</code> value to some other value (for example reset it to "<code>UNSPECIFIED</code>") and move the activity to background and to foreground again. The <code>MainActivity</code> is restored and its <code>TextView</code> contains "<code>New value</code>", however I expected it to be "<code>UNSPECIFIED</code>" - <strong>this is the problem</strong>.</p>
  
  <p>What is wrong with my app?</p>
  
  <p>The whole proto project may be downloaded <a href="http://www.box.net/shared/si6krushrv" rel="nofollow">here</a>.</p>
  
  <p>Here is my MainActivity code</p>
  
  <pre><code>private TextView tvValue;
  private EditText etNewValue;
  
  @Override
  public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
  
      tvValue = (TextView)findViewById(R.id.value);
      etNewValue = (EditText)findViewById(R.id.new_value);
  
      findViewById(R.id.reset).setOnClickListener(new OnClickListener() {         
          @Override
          public void onClick(View v) {
              tvValue.setText(getResources().getString(R.string.not_specified));
          }
      });
  
      findViewById(R.id.send_notification).setOnClickListener(new OnClickListener() {         
          @Override
          public void onClick(View v) {
              sendNotification(etNewValue.getText().toString());
          }
      });
  
      processDataFromBroadcast(getIntent());        
  }
  
  @Override
  public void onNewIntent(Intent intent) {
      super.onNewIntent(intent);
      processDataFromBroadcast(intent);
  }
  
  private void sendNotification(String value){
      NotificationManager mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
  
      String title = "Proto App Notif";
  
      Notification notification = new Notification(
              android.R.drawable.ic_notification_overlay,
              title,
              System.currentTimeMillis());
      notification.flags |= Notification.FLAG_AUTO_CANCEL;
  
      Context ctxApp = getApplicationContext();
  
      Intent notificationIntent = new Intent()
          .setAction(PushNotificationReceiver.ACTION_NOTIFICATION)
          .putExtra("value", value);
      PendingIntent contentIntent = PendingIntent.getBroadcast(
              ctxApp, 
              0, 
              notificationIntent, 
              PendingIntent.FLAG_UPDATE_CURRENT);     
  
      notification.setLatestEventInfo(
              ctxApp,
              title,
              value,
              contentIntent);
  
      notification.audioStreamType = AudioManager.STREAM_NOTIFICATION;
  
      mNotificationManager.notify(1, notification);           
  }
  
  private void processDataFromBroadcast(Intent intent) {
      if (!intent.hasExtra("value")){
          return;
      }
  
      String val = intent.getStringExtra("value");
  
      tvValue.setText(val); // Updating my activity look
  }
  </code></pre>
  
  <p>PushNotificationReceiver</p>
  
  <pre><code>private static final String LOG_CAT = "PushNotificationReceiver";
  static final String ACTION_NOTIFICATION = "com.mobiwolf.proto.NOTIFICATION_RECEIVER";
  
  @Override
  public void onReceive(Context context, Intent intent) {
      if (!intent.getAction().equals(ACTION_NOTIFICATION)) {
          return;
      }
  
      String value = intent.getStringExtra("value");
  
      Log.d(LOG_CAT, "Received notification message: "+value); // Log always contains the value sent on first time
  
      Intent i = new Intent();
      i.setClass(context, MainActivity.class);
      i.putExtra("value", value);
      i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  
      context.startActivity(i);
  }
  </code></pre>
  
  <p>And manifest</p>
  
  <pre><code>    &lt;receiver android:name="com.mobiwolf.proto.PushNotificationReceiver"&gt;
          &lt;intent-filter&gt;
              &lt;action android:name="com.mobiwolf.proto.NOTIFICATION_RECEIVER" /&gt;
          &lt;/intent-filter&gt;
      &lt;/receiver&gt;    
  
      &lt;activity android:name=".MainActivity"
                android:label="@string/app_name"
                android:launchMode="singleTask"&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;
  </code></pre>