title: How to open a fragment from a notification
body: <p>I'm writing a messaging app that makes use of fragments for various views. On the first fragment that is open, the user is presented with a list of contacts, and when he clicks on a contact, another fragment opens to show the existing chat window. This fragment is started with the following code:</p>
  
  <pre><code>FragmentManager fragmentManager = getFragmentManager();
  msgChat msgChatFragment = new msgChat();
  Bundle bundle = new Bundle(); 
  bundle.putString("userSelected", manageContact.getName());
  msgChatFragment.setArguments(bundle);
  fragmentManager.beginTransaction().replace(R.id.content_frame, msgChatFragment).addToBackStack(null).commit();
  getActivity().setTitle("Message Chat");
  </code></pre>
  
  <p>I also have a notification to inform the user of incoming messages. However, I'm having trouble launching the intended chat fragment when the user taps on the notification. My notification code is as follows:</p>
  
  <pre><code>Intent intent = new Intent(context, MainActivity.class);
  String notificationMessage = "My notification message";
  intent.setAction("Action1");
  intent.setFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
  intent.addCategory(Intent.CATEGORY_LAUNCHER);
  PendingIntent pIntent = PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT);
  NotificationCompat.Builder noti = new NotificationCompat.Builder(
    context).setContentTitle("My App")
    .setContentText(notificationMessage)
    .setSmallIcon(R.drawable.ic_stat_notify)
    .setContentIntent(pIntent).setAutoCancel(true)
    .setDefaults(Notification.DEFAULT_ALL);
  notificationManager.notify(notifyId, noti.build());
  </code></pre>
  
  <p>In my MainActivity's onResume(), I have the following code to catch the intent:</p>
  
  <pre><code>Intent intent = getIntent();
  try {
    String action = intent.getAction().toUpperCase();
  }catch(Exception e){
    Log.e(TAG, "Problem consuming action from intent", e);              
  }
  </code></pre>
  
  <p>However, getIntent() seems to always return a null value.</p>
  
  <p>What am I doing wrong? Thanks!</p>