Search code examples
androidwhatsappandroid-lazyloading

How does user's whatsapp application detects change in profile picture of its contact?


I was going through whatsapp application and I noticed that, for the first time it fetches thumbnails from the server, keeps them in cache memory, and thereafter it fetches these from the cache memory instead of server. (Like bitmap lazyloading).

Till now I have completed implementing the bitmap lazyloading part.

However I have a question as follows:

When any contact changes its profile picture how does the user's whatsapp application detects that particular change and how does it update that particular thumbnail only, cause the application is supposed to fetch the thumbnails from cache memory.

I am clueless about this. Any help is appreciated.

EDIT:

Does it use push notification to notify the client applications to update the corresponding profile thumbnail?


Solution

  • Source: WhatsApp is build upon C2DM and XMMP for message delivery. MQTT is another protocol which is used to minimise the battery usage.

    When any contact changes its profile picture how does the user's whatsapp application detects that particular change and how does it update that particular thumbnail only, cause the application is supposed to fetch the thumbnails from cache memory

    Answering your question: So WhatsApp may be using XMMP push or a GCM push notification(C2DM is deprecated ;] ) to inform all the client that some event has occurred and all it's client needs to take care of the same. In your case event is to update your profile pic in devices of your friends in WhatsApp contacts

    In your case, you can use GCM to update clients regarding such events. I don't have much idea about XMPP but You can also have a look at Smack API(An Open Source XMPP (Jabber) client library for instant messaging and presence) and this interesting post

    I hope I answered your question. Good Luck :)

    Edit:

    GCM is a service from Google that uses a persistent XMPP connection to communicate with Android devices. You can use any of the following techniques of GCM to achieve this.