It is often necessary to select the function of the contact in the project, if there is no special invitation, the system comes with the contact interface is sufficient:
Test Platform: Android 4.2
Display effect:
System comes with the interface call code:
1 New Intent (intent.action_get_content); 2 Intent.settype (ContactsContract.CommonDataKinds.Phone.CONTENT_ITEM_TYPE); 3 Startactivityforresult (Intent, 1);
To get the selected contact information, you need to make a carbon copy Onactivityresult
1 @Override2 protected voidOnactivityresult (intRequestcode,intResultCode, Intent data) {3 Super. Onactivityresult (Requestcode, ResultCode, data);4 if(Data! =NULL) {5Uri uri =Data.getdata ();6 if(URI! =NULL) {7cursor cursor =Getcontentresolver ()8 . Query (URI,9 Newstring[] {Contactscontract.commondatakinds.phone.number,contactscontract.commondatakinds.phone.display_ NAME},Ten NULL,NULL,NULL); One while(Cursor.movetonext ()) { AString number = cursor.getstring (0); -String name = cursor.getstring (1); - } the - } - } - +}
Call Android's own contact selection interface