I am looking for an example of the NotificationCompat.Builder's method addPerson.
From the documentation I can see that I can either provide the contact's CONTENT_LOOKUP_URI or that the system can also resolve mailto: or tel: schemes.
Given this, here is my test:
- I created an Android P emulator
- I added a contact to the contact provider (through the Contacts app) with an email address foo@bar.com
Then I used mailto: scheme with the following code :
private fun createNotification(contactEmail: String) {
val mBuilder = NotificationCompat.Builder(this, NOTIFICATION_CHANNEL_ID)
.setSmallIcon(R.drawable.ic_chat_black_24px)
.setContentTitle("Contact found")
.setContentText("Contact $contactEmail")
.setShowWhen(true)
.addPerson("mailto:$contactEmail")
val mNotificationManager = NotificationManagerCompat.from(this)
mNotificationManager.notify(1, mBuilder.build())
}
The notification is well displayed but I cannot see the association with the contact or person. How is it supposed to look like and how can I know if it worked ? As I cannot notice anything (even a log) I suppose that it does not work.
Also, if you are not using the mailto: or tel: scheme, how are you supposed to retrieve the contact's CONTENT_LOOKUP_URI ?
Any pointer or code sample would help. Thanks !