Is there a simple way to check if an incoming caller is a contact in Android? -
When an Android phone receives a call, it automatically checks whether the call is present in its contact database I was thinking that there is an easy way to access that information. I have a PhoneStateListener
that does some work during a ringing situation, and I have to see if incoming callers are in contact list or not.
Is there no way to do this contact ContentProvider
?
is using the phone app contacts ContentProvider
as well; I'm not sure how you want to avoid that, besides, it is the only publicly accessible way to access that information.
Resolving a number for a name (pre 2.0, in this case) is quite simple:
Uri Uri = Uri. Expected word (phone. CONTENT_FILTER_URL, Uri.node (number)); String name = null; Cursor cursor = context.getContentResolver (). Query (Yuri, New String [] {Phones.DISPLAY_NAME}, Blank, Blank, Blank); If (cursor! = Null & amp; cursor.more ()) {name = cursor.getString (cursor.getColumnIndex (phones.DISPLAY_NAME)); Cursor.close (); }
Comments
Post a Comment