Please consult Daniel! Questions about how Android queries your contacts by phone number.

Source: Internet
Author: User

============ Problem Description ============


 private void getcontactpeople (String incomingnumber)     {     mytextview1.settextcolor (Color.Blue);     contentresolver contentresolver  = getcontentresolver ();    cursor cursor = null;         String[] projection = new String[]     {    ContactsContract.Contacts._ID,     Contactscontract.contacts.display_name,    contactscontract.commondatakinds.phone.number     };    cursor = contentresolver.query ( contactscontract.commondatakinds.phone.content_uri, projection,          ContactsContract.CommonDataKinds.Phone.NUMBER +  "=?", new string[]         { incomingNumber },  "");     if (Cursor.getcount ()  == 0)     {     mytextview1.settext ("Unknown number:"  + incomingnumber);     }     else if  (Cursor.getcount ()  > 0)     {     cursor.movetofirst ();     string name = cursor.getstring (1 );     mytextview1.settext (name +  ":"  + incomingnumber);     }    }

The code is to query the name of the contact in the Address book based on the phone number. Contacts have Incomingnumber number of contacts, but Cursor.getcount () is equal to 0, ask what is the reason, the program should be how to change.

============ Solution 1============


I used your method to write a running program, share the code
http://download.csdn.net/detail/qianqucaicaizi/4276224

Please consult Daniel! Questions about how Android queries your contacts by phone number.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.