title: Send broadcast on notification click
body: <p>I have an application which is basically a webview and GCM notifications. I want to achieve the following thing: If the user is in the app and receives a notification, when he clicks the notification I want the webview to load the url provided in the notification.</p>
  
  <p>I'm trying to accomplish this by using broadcast receiver but it doesn't work.</p>
  
  <p>I dynamically register the receiver in the MainActivity:</p>
  
  <pre><code>private void registerNotificationReceiver() {
          final IntentFilter filter = new IntentFilter();
          filter.addAction(ACTION_LOAD_URL_FROM_NOTIFICATION);
          Log.i(TAG, "registerNotificationReceiver()");
          this.receiver = new BroadcastReceiver() {
  
              @Override
              public void onReceive(Context context, Intent intent) {
                  Log.d(TAG, "notification received");
  
              }
          };
  
          super.registerReceiver(this.receiver, filter);
      }
  </code></pre>
  
  <p>And in the GCM Listener I'm using PendingIntent.getBroadast():</p>
  
  <pre><code>final Intent broadcastIntent = new Intent(MainActivity.ACTION_LOAD_URL_FROM_NOTIFICATION);
          PendingIntent intent = PendingIntent.getBroadcast(getApplicationContext(), 0, broadcastIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  
          notificationBuilder.setContentIntent(intent);
  
          notification = notificationBuilder.build();
          notification.flags |= Notification.FLAG_AUTO_CANCEL;
  
          NotificationManager mNotificationManager =
                  (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
          mNotificationManager.notify(1, notification);
  </code></pre>
  
  <p>I don't understand why onReceive in the MainActivity class is not called. The message "notification received" is not displayed. 
  Can you help me? Thank you :)</p>