Preface
When reading the address book of the Android system, the contacts are generally read first and then their numbers are read in a nested loop. If the number of contacts in the address book is small, the speed is acceptable, but the number of people in the address book is 1 to 2, I am afraid it will be slow. If the hardware is almost worse, the experience will be worse. Available
ContactsContract. CommonDataKinds. Phone. CONTENT_URI (corresponding to the contacts2.db data view metadata) view to avoid nested reading, but PhoneLookup. CONTENT_FILTER_URI cannot be used directly. Here are some tips.
Statement
You are welcome to repost, but please keep the original source of the article :)
Blog: http://www.cnblogs.com
Farmer's uncle: http://over140.cnblogs.com
Body
1. General Usage of PhoneLookup. CONTENT_FILTER_URI
Uri uri = Uri. withAppendedPath (PhoneLookup. CONTENT_FILTER_URI, Uri. encode (phoneNumber ));
Resolver. query (uri, new String [] {PhoneLookup. DISPLAY_NAME ,...
For the API, see here. If you use PhoneLookup. CONTENT_FILTER_URI as follows, the IllegalArgument Exception error is returned.
GetContentResolver (). query (PhoneLookup. CONTENT_FILTER_URI ,...
Ii. Tips and usage
Cursor c = getContentResolver (). query (Uri. withAppendedPath (
PhoneLookup. CONTENT_FILTER_URI, "*"), new String [] {
PhoneLookup. _ ID,
PhoneLookup. NUMBER,
PhoneLookup. DISPLAY_NAME,
PhoneLookup. TYPE, PhoneLookup. LABEL}, null, null, sortOrder );
The key is this "*". In this way, you can obtain the names of all numbers, related contacts, and other related fields, which is much easier than searching for their numbers through contacts.
Iii. Maintenance
2011-10-28 this test program passed the G7 test. The Android version is 2.2. Please also test it in this version or later. Please understand that the test conditions have not been specified before :)
End
The company's project is about to be tested and we look forward to seeing you early.