title: Android - Sending Push Notifications via GCM with app in foreground/background
body: <p>I'm adding Push Notifications via GCM to my app, but I am stuck on something.</p>
  
  <p>When I send a Push Notification with my app on foreground (open and on screen), it displays normally, as intended:</p>
  
  <p><img src="https://i.stack.imgur.com/frZgG.png" alt="Push Notification with app on Foreground"></p>
  
  <p>But when I send it with my app on background, it displays like this:</p>
  
  <p><img src="https://i.stack.imgur.com/Z5uRI.png" alt="Push Notification with app on Background"></p>
  
  <p>So my large image and icon background color doesn't display.</p>
  
  <p>Code for GCM HTTP Call:</p>
  
  <pre><code>{
    "notification": {
      "title": "Tecolutla, Veracruz",
      "body": "¡Bienvenidos a Tecolutla!",
      "icon": "push"
    },
    "priority": "high",
    "data": {
      "Mensaje": "Descubre muchísimos lugares en Visita Xalapa.",
      "Class" : "Festividades"
    },
    "to": "/topics/global"
  }
  </code></pre>
  
  <p>Code for GsmListenerService:</p>
  
  <pre><code>@SuppressWarnings("ConstantConditions")
      private void sendNotification(Bundle data) {
          Intent intent = new Intent(this, TecolutlaVeracruz.class);
          intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
          intent.putExtra("Push_Title", data.getBundle("notification").getString("title"));
          intent.putExtra("Push_Body", data.getBundle("notification").getString("body"));
          intent.putExtra("Push_Mensaje", data.getString("Mensaje"));
          int Color = ColorManager.getColorBase(Main.INICIO);
          if(data.containsKey("Class")){
              if(data.getString("Class").equals("Inicio")) Color = ColorManager.getColorBase(Main.INICIO);
              else if(data.getString("Class").equals("Nuestro Municipio")) Color = ColorManager.getColorBase(Main.NUESTRO_MUNICIPIO);
              else if(data.getString("Class").equals("Festividades")) Color = ColorManager.getColorBase(Main.FESTIVIDADES);
          }
          PendingIntent pendingIntent = PendingIntent.getActivity(this, 0 /* Request code */, intent, PendingIntent.FLAG_ONE_SHOT);
          NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this)
                  .setSmallIcon(R.mipmap.push)
                  .setLargeIcon(BitmapFactory.decodeResource(getResources(), R.drawable.acercade_applogo))
                  .setContentTitle(data.getBundle("notification").getString("title"))
                  .setContentText(data.getBundle("notification").getString("body"))
                  .setAutoCancel(true)
                  .setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION))
                  .setColor(Color)
                  .setVibrate(new long[]{ 0, 100, 200, 300 })
                  .setContentIntent(pendingIntent);
          NotificationManager notificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
          notificationManager.notify(0 /* ID of notification */, notificationBuilder.build());
      }
  </code></pre>
  
  <p>Another issue I have, is that the notification won't display if the app is killed or not running. Is this normal?</p>