3

Can anyone help me out in understanding, How WhatsApp and imo apps are syncing contacts immediately after add/delete/updating contact.

I have tried following method:

  1. Tried to register ContentObserver in service so that we can get contact which is updated.

  2. If we able to deploy a ContentObserver to contacts database, how do we differentiate manual and programatic updating of a contact.

Note: I am using Sync adaptor to sync the contacts with server but not able to get trigger points for sync process.

Please help me.

Burhanuddin Rashid
  • 5,260
  • 6
  • 34
  • 51
Manu
  • 147
  • 2
  • 12
  • 1
    My whatsapp has an "update" button in contact tab, so probably it's not automatic, simply they do it every app's launch or every click on the button – Pier Giorgio Misley Oct 19 '16 at 13:26
  • thanks for the reply,but i am looking for method, when there is operation(add/delete/update) with respect to contacts data and return contact which is updated, because its taking time to sync all the contacts each time. it will be so good if i just sync updated contacts. – Manu Oct 19 '16 at 13:50
  • have you got the solution ? – Bhoomi Zalavadiya Jan 03 '18 at 05:11

1 Answers1

1

Sync adapter has an option to force sync or immediate sync . From documentation the method is similar to the snippet below

public void onRefreshButtonClick(View v) {
        ...
        // Pass the settings flags by inserting them in a bundle
        Bundle settingsBundle = new Bundle();
        settingsBundle.putBoolean(
                ContentResolver.SYNC_EXTRAS_MANUAL, true);
        settingsBundle.putBoolean(
                ContentResolver.SYNC_EXTRAS_EXPEDITED, true);
        /*
         * Request the sync for the default account, authority, and
         * manual sync settings
         */
        ContentResolver.requestSync(mAccount, AUTHORITY, settingsBundle);
    }
Mithun Sarker Shuvro
  • 3,902
  • 6
  • 32
  • 64
  • thanks for the reply, i am looking for method, when there is operation(add/delete/update) with respect to contacts data and return contact which is updated. – Manu Oct 19 '16 at 13:49
  • because its taking time to sync all the contacts each time. it will be so good if i just sync updated contacts. – Manu Oct 19 '16 at 13:54
  • The whole process is done in background, so I don't think it won't affect user experience – Mithun Sarker Shuvro Oct 20 '16 at 05:11