title: Sending Message to Application from Server- Connecting the GCM
body: <p>I try to implement an application with Google Cloud Messaging from <a href="http://developer.android.com/guide/google/gcm/gs.html" rel="nofollow">http://developer.android.com/guide/google/gcm/gs.html</a> </p>
  
  <pre><code>Sender sender = new Sender(myApiKey);
  
                  Message message = new Message.Builder()
                  .collapseKey("1")
                  .timeToLive(3)
                  .delayWhileIdle(true)
                  .addData("message", "message is created at builder")
                  .build();
  
                  Result result = sender.send(message, reGid, 5);
                  System.out.println("result of message is "+result);
  </code></pre>
  
  <p>and consequently i get a message id and can see from console; but i want to show message at my device with a toast.</p>
  
  <p>GCMIntentService.java:</p>
  
  <pre><code>@Override
  protected void onMessage(Context arg0, Intent arg1) {
      Log.i(TAG, "new message= ");
      Toast.makeText(this, arg1.getStringExtra("message"), Toast.LENGTH_SHORT)
              .show();
  }
  </code></pre>
  
  <p>from GCM Advanced Topics:</p>
  
  <p><em>When a 3rd-party server posts a message to GCM and receives a message ID back, it does not mean that the message was already delivered to the device. Rather, it means that it was accepted for delivery. What happens to the message after it is accepted depends on many factors.
  In the best-case scenario, <strong>if the device is connected to GCM</strong>, the screen is on, and there are no throttling restrictions (see Throttling), the message will be delivered right away.</em></p>
  
  <p>I can't understand what means "<strong>the device is connected to GCM</strong>".
  How can device connect the GCM, connecting the internet and running the application from device isn't enough?</p>