title: Passing intent extras from a google cloud message receiver to activity is null
body: <p>I have a broadcast receiver that listens for cloud messages, I can display the notification fine but when the user clicks the notification I want to route them to the proper activity with intent extras. The extras are always null. </p>
  
  <p>I can verify that the intent passed to pending intent does have extras while debugging. </p>
  
  <p>I try to pick up on the intents in the activites onCreate() method </p>
  
  <p>***EDIT adding working code, there are a few things to note, you can not count on the oncreate() method to be called if the task is already started so it seems to best place to get the extras is in the onresume method. I needed to set the flags on the intent and on the pending intent </p>
  
  <pre><code>@EReceiver
  public class MyBroadcastReceiver extends BroadcastReceiver {
  
  private static final String TAG = "googlecloudmessage";
  private static final int NOTIFICATION_ID = 1;
  private NotificationManager mNotificationManager;
  private NotificationCompat.Builder builder;
  private Context ctx;
  
  @Pref
  public MyPrefs_ myPrefs;
  
  @Override
  public void onReceive(Context context, Intent intent) {
  
      Log.d(TAG, "received gcm message");
  
      GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context);
      this.ctx = context;
  
      String messageType = gcm.getMessageType(intent);
  
      if (messageType != null) {
  
          if (GoogleCloudMessaging.MESSAGE_TYPE_SEND_ERROR.equals(messageType)) {
  
          }
          else if (GoogleCloudMessaging.MESSAGE_TYPE_DELETED.equals(messageType)) {
  
          }
          else if (messageType.equalsIgnoreCase("gcm")) {
              myPrefs.notification().put(true);
              handleNotification(intent);
          }
      }
      setResultCode(Activity.RESULT_OK);
  }
  
  private void handleNotification(Intent intent) {
  
      Bundle bundle = intent.getExtras();
  
      String typeString = bundle.getString("type");
      String icon = bundle.getString("icon");
  
      String title = null;
      String body = null;
      Class&lt;?&gt; intentClass = null;
      Integer intentExtraId = null;
  
      if (typeString == null)
          return;
  
      int type = Integer.parseInt(typeString);
  
      switch (type) {
  
      case 1:
  
          intentClass = FriendsActivity_.class;
  
          title = bundle.getString("username");
  
          break;
  
      case 2:
  
          intentClass = UserProfileActivity_.class;
  
          title = bundle.getString("username");
  
          intentExtraId = Integer.parseInt(bundle.getString("user_id"));
  
          break;
  
  
  
  
      }
  
  
      mNotificationManager = (NotificationManager) ctx.getSystemService(Context.NOTIFICATION_SERVICE);
  
  
  Intent i = new Intent();
      i.setClass(ctx, intentClass);
      i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP     | Intent.FLAG_ACTIVITY_CLEAR_TOP);
      i.putExtra("gcm", true);
      if (intentExtraId != null) {
  
          i.putExtra("id", intentExtraId);
      }
  
      int requestID = (int) System.currentTimeMillis();
  
      PendingIntent pendingIntent = PendingIntent.getActivity(ctx, requestID, i,     PendingIntent.FLAG_UPDATE_CURRENT);
  
      NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(ctx);
  
      mBuilder.setSmallIcon(R.drawable.ic_stat_u);
  
      Bitmap bmp = null;
  
      try {
          bmp = Ion.with(ctx, ctx.getResources().getString(R.string.image_container) + icon).asBitmap().get();
      }
      catch (InterruptedException e) {
  
          e.printStackTrace();
      }
      catch (ExecutionException e) {
  
          e.printStackTrace();
      }
  
      if (icon != null) {
          mBuilder.setLargeIcon(bmp);
      }
  
      mBuilder.setContentTitle(title).setStyle(new NotificationCompat.BigTextStyle().bigText(body))
              .setContentText(body);
  
      mBuilder.setContentIntent(contentIntent);
      mNotificationManager.notify(NOTIFICATION_ID, mBuilder.build());
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Activity</p>
  
  <pre><code> @Override
  protected void onNewIntent(Intent intent) {
      super.onNewIntent(intent);
      setIntent(intent);
  }
  
  @Override
  protected void onResume() {
  
      super.onResume();
  
      Integer newId = getIntent().getExtras().getInt("id");
  
      id = newId;
  
  
  }
  </code></pre>