Name obtained by phone number

Source: Internet
Author: User
Name obtained by phone number

Hot1 Read twice 21 hours ago Tags: Phone number before 2.0: Public String getname (context CTX, string number ){ String [] projection = new string [] { Contacts. Phones. display_name, Contacts. Phones. Number }; // Encode the phone number and build the filter URI Uri contacturi = URI. withappendedpath (contacts. Phones. content_filter_url, Uri. encode (number )); // Query time Cursor c = CTX. getcontentresolver (). Query (contacturi, projection, null, Null, null ); // If the query returns 1 or more results // Return the first result If (C. movetofirst ()){ String name = C. getstring (C. getcolumnindex (contacts. Phones. display_name )); Log. D ("debug", "XYZ _" + name + "is calling "); Return name; } Return ""; }
2.0 and later: Public String getname (context CTX, string number ){ Uri uri = URI. withappendedpath (contactscontract. phonelookup. content_filter_uri, Uri. encode (number ));
// Query the filter URI String [] projection1 = new string [] {phonelookup. display_name }; Cursor cursor1 = CTX. getcontentresolver (). Query (Uri, projection1, null ); If (cursor1.movetofirst ()){ String name = cursor1.getstring (cursor1 . Getcolumnindex (phonelookup. display_name )); Int phonenameindex = cursor1.getcolumnindex (phonelookup. display_name ); String phonenamestr = cursor1.getstring (phonenameindex ); Log. D ("debug", "XYZ _" + phonenamestr + "is calling "); Return name; } Return "";}

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.