0

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 !

Showpath
  • 3
  • 2
  • what execlty you want to do, do you want to show person name and email send option? – Rajshree Tiwari Jul 25 '18 at 12:19
  • @RajshreeTiwari for instance yes but I know I could use a notification action. I want to know what this feature is supposed to do. For instance would it allow me to display the contact's thumbnail as the notification icon ? – Showpath Jul 25 '18 at 12:54

1 Answers1

0

The documentation states: "Depending on user preferences, this annotation may allow the notification to pass through interruption filters, and to appear more prominently in the user interface." So I guess to test this feature you should go into your emulator settings -> sound -> Do not disturb here you see the exceptions. When in do not disturb mode, if the email address you are passing belongs to someone in the "exceptions" the notification will be displayed otherwise it won't.

Sebastien
  • 26
  • 2