我的代码在这里我想获取联系人姓名。如何获取whatsapp联系人姓名。
String adress = intent.getStringExtra("contact");
String phone = adress.split("@")[0];
String[] projection = new String[] {ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME,
ContactsContract.CommonDataKinds.Phone.NUMBER,
ContactsContract.CommonDataKinds.Phone.NORMALIZED_NUMBER };
ContentResolver cr=getContentResolver();
String selection = ContactsContract.CommonDataKinds.Phone.NORMALIZED_NUMBER + " = " + phone;
Cursor c = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, projection, selection, null, null);
int contactnameColumn=c.getColumnIndex(ContactsContract.RawContacts.DISPLAY_NAME_PRIMARY);
if (c != null && c.moveToFirst()) {
Log.e(TAG, "name: "+ c.getString(0));
Toast.makeText(getApplicationContext(),"name:"+c.getString(0),Toast.LENGTH_SHORT).show()