2

Yesterday, I got a Foursquare friend request in the notifications panel.

The only running services at that time were, I believe, the same that are running now. Definitely there was no Foursquare service running. I hadn't used Foursquare in weeks. From Settings:

  • Settings

  • Google Services (GoogleLocationService)

  • WhatsApp

  • My Calendar

  • Google Services (Cloud to Device Messa…, Google Messaging Ser…)

  • Maps

  • Android keyboard

I was logged into Google Latitude.

By what mechanism did the friend request reach the notifications panel?

  • 2
    Push notification, I expect. If you could only receive notifications from apps that are running there are a lot of notifications I'd be missing. – ale May 25 '13 at 13:32
  • @AlEverett I wonder why Whatsapp is not using push notification. The Whatsapp service is quite heavy weight at 13MB! – feklee May 25 '13 at 14:24
3

When Google Cloud Messaging receives a message from Google, it sends a broadcast to the related app. The app can receive this broadcast even if no service was running, and it can respond by starting a service, or by creating a notification from within the broadcast receiver itself.

Part of the Android developers' documentation explains the process step-by-step. There's a lot of detail there that you only need to know to write an app that uses Google Cloud Messaging, but it might help satisfy your curiosity.

  • So Foursquare instructed Google to send a broadcast a message to the Foursquare app on my phone? Why call it broadcast, if it's only to one app? If you could outline the process step by step, then that would be great! – feklee May 25 '13 at 14:22
  • 1
    It's called a broadcast because the same mechanism is used within your phone to inform many apps of an event, such as connecting to a network. I wrote up an explanation of services and broadcast receivers which may help. – Dan Hulme May 25 '13 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.