Android-ContactPicker
Android-ContactPicker copied to clipboard
How to display contact number only in textview
i am able to display name but i cant able to send message with selected name is there any way to show only number instead of name.
I fixed it to display phone numbers in edit Text. Go to the activity where you are sending messages and locate the populateContact method: Then modify as follows:
private void populateContact(SpannableStringBuilder result, ContactElement element, String prefix) { long tphoneid=element.getId(); String phone = null; String tphoneid2=Long.toString(tphoneid); ContentResolver cr = getContentResolver(); Cursor cp = cr.query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, ContactsContract.CommonDataKinds.Phone.CONTACT_ID + " = ?", new String[]{tphoneid2}, null); if (cp != null && cp.moveToFirst()) { phone = cp.getString(cp.getColumnIndex(ContactsContract.CommonDataKinds.Phone.NUMBER)); cp.close(); }
String displayName=phone;
displayName.replaceAll("\\s","");
result.append(prefix);
result.append(displayName + ",");
//result.setSpan(new BulletSpan(15), start, result.length(), Spanned.SPAN_INCLUSIVE_EXCLUSIVE);
}