Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to display contact number only in textview #35

Open
son2017 opened this issue Nov 23, 2017 · 1 comment
Open

How to display contact number only in textview #35

son2017 opened this issue Nov 23, 2017 · 1 comment

Comments

@son2017
Copy link

son2017 commented Nov 23, 2017

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.

@C-Spydo
Copy link

C-Spydo commented Jun 27, 2018

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);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants