0

I'm making an Android app (API 2.3.3) and it will send/receive text messages. I can the originating address for received messages by using getOriginatingAddress() method and it will give me a normal phone number in the phone +(country code)(number). (eg: +94713594206 for Sri Lankan numbers).

The question is, I need to check whether a contact with this received number already exists on the user's phone. If it does, get the corresponding name (Display Name) and the photo (if any) matching this number. If not, just show the raw number.

So can anyone please help me with the first instance- checking if a contact already exist that matches the given phone number, and if does exist, get the display name and photo of this matched contact?

Thanks.

Roshnal
  • 1,284
  • 3
  • 16
  • 39
  • Possible duplicate of [this](http://stackoverflow.com/questions/3712112/search-contact-by-phone-number) - there's everything you need – Lukas Olsen Sep 02 '12 at 10:58
  • @LukasOlsen Thanks, I got the name. But how do I get the photo? I can use `PHOTO_ID` or something, but an actual Bitmap of the photo? – Roshnal Sep 02 '12 at 11:12
  • [This](http://stackoverflow.com/questions/7738192/how-to-get-contact-photo-uri) should answer every question! – Lukas Olsen Sep 02 '12 at 11:15
  • @LukasOlsen Thanks again :) That solved it... Should I close the question or will you post those two links as an answer so that I could accept it? – Roshnal Sep 02 '12 at 11:19

1 Answers1

2

Possible duplicate of this: Search contact by phone number - there's everything you need

and for the photo question: This one: how to get contact photo URI solves the problem!

Community
  • 1
  • 1
Lukas Olsen
  • 5,294
  • 7
  • 22
  • 28