title: Get Notification Message in Activity
body: <p>I am allowing user to do <code>Tap</code> on <code>Notification</code> then <code>Launching App</code> and <code>opening</code> a particular <code>Activity</code>.</p>
  
  <p>In that <code>Activity</code>, which I am opening I would like to get <code>message</code> which I sent via Notification</p>
  
  <p><strong>SendNotification(...) method:</strong></p>
  
  <pre><code>private void sendNotification(String messageTitle, String messageBody, Bitmap image, String TrueOrFalse) {
  
      Intent intent = new Intent(this, MainActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      intent.putExtra("AnotherActivity", TrueOrFalse);
  
      PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent,
              PendingIntent.FLAG_ONE_SHOT);
  
      Uri defaultSoundUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
      NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
              .setLargeIcon(image)/*Notification icon image*/
              .setSmallIcon(R.mipmap.ic_launcher)
              .setContentTitle(messageTitle)
              .setContentText(messageBody)
              .setStyle(new NotificationCompat.BigPictureStyle()
                      .bigPicture(image))/*Notification with Image*/
              .setAutoCancel(true)
              .setSound(defaultSoundUri)
              .setContentIntent(pendingIntent);
  
      NotificationManager notificationManager =
              (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
  
      notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
  }
  </code></pre>
  
  <p><strong>AnotherActivity.java:</strong></p>
  
  <pre><code>public class AnotherActivity extends AppCompatActivity {
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
  
          setContentView(R.layout.activity_another);
  
          // here I would like to get value of messageBody
      }
  
  }
  </code></pre>
  
  <p>UPDATE #1</p>
  
  <p><strong>sendNotification</strong>(...) {</p>
  
  <pre><code>    Intent intent = new Intent(this, MainActivity.class);
      intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
      intent.putExtra("YouTubeActivity", TrueOrFalse);
      intent.putExtra("message", messageTitle);
  
      ....
  
      }
  </code></pre>
  
  <p>Tried both the ways in <code>onCreate()</code> of <strong>AnotherActivity.java</strong> but did not get the message</p>
  
  <pre><code>        String message=getIntent().getStringExtra("message");
          Toast.makeText(YouTubeActivity.this, message, Toast.LENGTH_LONG).show();
  
          Bundle extras = getIntent().getExtras();
          if (extras != null) {
              String value = extras.getString("message");
              Toast.makeText(YouTubeActivity.this, value, Toast.LENGTH_LONG).show();
              //The key argument here must match that used in the other activity
          }
  </code></pre>