List of usage examples for android.telephony PhoneNumberUtils formatNumber
public static String formatNumber(String phoneNumber, String phoneNumberE164, String defaultCountryIso)
From source file:com.android.dialer.calllog.ContactInfoHelper.java
/** * Format the given phone number//w ww . j a va 2 s. c o m * * @param number the number to be formatted. * @param normalizedNumber the normalized number of the given number. * @param countryIso the ISO 3166-1 two letters country code, the country's convention will be * used to format the number if the normalized phone is null. * * @return the formatted number, or the given number if it was formatted. */ private String formatPhoneNumber(String number, String normalizedNumber, String countryIso) { if (TextUtils.isEmpty(number)) { return ""; } // If "number" is really a SIP address, don't try to do any formatting at all. if (PhoneNumberHelper.isUriNumber(number)) { return number; } if (TextUtils.isEmpty(countryIso)) { countryIso = mCurrentCountryIso; } return PhoneNumberUtils.formatNumber(number, normalizedNumber, countryIso); }
From source file:com.android.mms.ui.ComposeMessageActivity.java
private void updateTitle(ContactList list) { String title = null;//from w ww.ja va2 s . c om String subTitle = null; int cnt = list.size(); switch (cnt) { case 0: { String recipient = null; if (mRecipientsEditor != null) { recipient = mRecipientsEditor.getText().toString(); } title = TextUtils.isEmpty(recipient) ? getString(R.string.new_message) : recipient; break; } case 1: { title = list.get(0).getName(); // get name returns the number if there's no // name available. String number = list.get(0).getNumber(); if (!title.equals(number)) { subTitle = PhoneNumberUtils.formatNumber(number, number, MmsApp.getApplication().getCurrentCountryIso()); } break; } default: { // Handle multiple recipients title = list.formatNames(", "); subTitle = getResources().getQuantityString(R.plurals.recipient_count, cnt, cnt); break; } } mDebugRecipients = list.serialize(); ActionBar actionBar = getActionBar(); actionBar.setTitle(title); actionBar.setSubtitle(subTitle); }