2

How to retrieve the contact name from incoming call number?

indira
  • 6,321
  • 18
  • 62
  • 79

2 Answers2

4

TelephonyManager.EXTRA_INCOMING_NUMBER

Muhammad Shahab
  • 5,255
  • 4
  • 36
  • 47
2

First you need to get the incoming caller number which you can manage with the help of below reference question:
Retrieve incoming call's phone number in Android

So once you have the number, you can use the below code to get the contact name:

Uri uri = Uri.withAppendedPath(PhoneLookup.CONTENT_FILTER_URI, Uri.encode(phoneNumber));
resolver.query(uri, new String[]{PhoneLookup.DISPLAY_NAME} .....)
Cœur
  • 34,719
  • 24
  • 185
  • 251
Ashish
  • 9,878
  • 5
  • 65
  • 79
  • Thanks Rohit. The application works smoothly when I add READ_CONTACT permission – indira Mar 16 '11 at 11:47
  • Unfortunately, the link has rotted and your answer is useless. If you can please [edit] to give an answer that doesn't link to an outside source (except as a reference), it will be deleted. –  Mar 05 '12 at 18:39