androidandroid-contentproviderandroid-contactscalllog

Android: how to provide data about numbers from application database to android phone app - recents


How can I make android default phone app take the assigned name to the number from my application database and show it?

An example of what I want to achieve:
Number XXX-XXX-XXX called me yesterday and I don't have its name in my Contact Book BUT I have its name in my application database so in phone app - recents will be shown name of contact from my app database instead of XXX-XXX-XXX.


Solution

  • It is possible by writing values to CACHED_NAME field in the CallLog.Calls table.

    However there are two issues with this:

    1. Call Log access in Google Play apps is only allowed for very specific use-cases, see: https://support.google.com/googleplay/android-developer/answer/10208820?hl=en
    2. Most, if not all, Phone apps will refresh the CACHED_NAME field when launched, so it will query the Contacts table for that phone number, will not find any contact with that number and will then clear the name.

    The only viable solution would be to create a new RawContact per phone-number in your app, with a simple Phone row and a StructuredName row.

    This will add those numbers to the user's Contacts table, and will also present the names in the call-log app.