• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps PhoneLookup help

mathkid95

Newbie
Hi,

I am working with the android ContactsContract.PhoneLookup class, and I needed some help with it.

ContactsContract.PhoneLookup | Android Developers

What I am trying to do is check if a given number is on my contacts list or not, regardless of type. So my logic was get the incoming number, and use the cursor and query provided by this class to see if the given numbers matches a number on the contacts list. If not, then it should be forwarded to voicemail, but I will worry about that later.

Now I understand I can use my own cursor and obtain all the numbers, get the incoming number, and write my own method to check, but I really want to use this class because it is highly optimized.

When I tested this out, I saw that the number will show on screen (I made this happen with a TextView) only if the number I entered the for Uri.encode is on my contacts list. When I change the number so that it is not on my contacts list, then nothing is shown on screen. Why? I made a TextView to show the number, but nothing is shown.

Can you please help?

Thanks!
 
This is what i would do:
- Create a BroadcastReceiver class which receives android.intent.action.PHONE_STATE
- In the receiver class check: intent.getStringExtra("EXTRA_STATE").equals(TelephonyManager.EXTRA_STATE_RINGING")
- Get the number from intent.getStringExtra("EXTRA_NUMBER")
- And then do the query from the PhoneLookup class
 
Back
Top Bottom