2

Whatsapp provides a hidden feature to the message, voice call or video call any registered user who is also in your contacts list. See the attached image. These options are available on different contacts app as well, so it not the contacts app which is doing the job.

Now after some researching, I have some faint idea about how they are doing it. These apps(WhatsApp, truecaller, paytm etc) are creating their own contacts and other contacts app is simply looking for contact providers and showing all the available options for any particular contact.

I am looking for some reference material or guide to achieve the same. Thanks.

Whatsapp functions within other contacts apps

                                     

marmor
  • 27,641
  • 11
  • 107
  • 150
R2D2
  • 31
  • 2
  • 5
  • Guess its related to https://developer.android.com/guide/topics/providers/contacts-provider.html#SocialStream – Monish Kamble Dec 29 '17 at 08:24
  • 1
    Important information for someone reading in future. "Changes to the structured name, organization, phone number, email address, or nickname trigger a re-aggregation." – Ranjan Jan 10 '18 at 11:37

1 Answers1

1

You need an Contacts account, a SyncAdapter, and to add custom RawContacts with custom mimetype (for each action) for all contacts you want to add actions to.

See this: https://stackoverflow.com/a/42642971/819355 And this: https://stackoverflow.com/a/42005334/819355

marmor
  • 27,641
  • 11
  • 107
  • 150
  • So after a lot of reading my understanding is that I have to modify the `ContactsContract.Data` table and add my app specific data(more data e.g. `account_name`, `account_type`, `mime_type` etc. for any particular contact `_ID` of `ContactsContract.Contacts`) in that table. Is this correct? – R2D2 Jan 01 '18 at 12:55
  • Well I have to modify the `ContactsContract.RawContacts` table as well. – R2D2 Jan 02 '18 at 06:39
  • I was able to add RawContacts and Data exactly like other apps, but options for custom MIME_TYPE are still not appearing. Also I can see that my Contact data is shown as "Phone-only, unsynced contact", maybe this is the problem. I even added "IsCallerSyncAdapter" string to query as mentioned [here](https://developer.android.com/guide/topics/providers/contacts-provider.html#ContactsProviderMetadata). – R2D2 Jan 02 '18 at 12:00
  • have you aggregated your custom RawContact into an existing RawContact(s)? if not see this: https://stackoverflow.com/a/40869351/819355 – marmor Jan 02 '18 at 18:39
  • Aggregation is not the problem. I logged all the table data and found it to be consistent for all RawContact and Data rows. Problem seems to be with SyncAdapter or elsewhere. I followed [this](https://github.com/dkostyrev/SampleContacts) sample code as well and it is working as expected(he didn't use aggregation but also created a new account instead of using existing). Currently I can see my added data in the contact's details but no options for mime_type. See [here](https://imgur.com/IJWcRtR). I'll try aggregation as well and keep you posted. – R2D2 Jan 02 '18 at 19:22
  • 1
    Its working now. Problem was in SyncAdapter's xml file where contentAuthority value was supposed to be "com.android.contacts" but I was using some custom authority. Thanks. – R2D2 Jan 03 '18 at 11:52