title: Formatting phone number to E164 format in Android
body: <p>I want convert every phone number from conatct in device to E164 format.
  So, I used opensource below.</p>
  
  <p><a href="https://github.com/googlei18n" rel="noreferrer">libphonenumber</a></p>
  
  <p>So I used it like here.</p>
  
  <pre><code>Phonenumber.PhoneNumber formattedNumber = null;
  String formatted = null;
  
  try {
      formattedNumber = phoneUtil.parse(phoneNumber, "KR");
      formatted = phoneUtil.format(formattedNumber,PhoneNumberUtil.PhoneNumberFormat.E164);
  
      if (StringUtils.isEmpty(formatted) == false &amp;&amp; formatted.length() &gt; 0 &amp;&amp; StringUtils.isEmpty(name) == false &amp;&amp; name.length() &gt; 0) {
          listName.add(name);
          listPhoneNumber.add(formatted);
      }
  } catch (NumberParseException e) {
      continue;
  }
  </code></pre>
  
  <p>And I read that this library is used by the Android framework since 4.0.</p>
  
  <blockquote>
    <p>The Java version is optimized for running on smartphones, and is used by the Android framework since 4.0 (Ice Cream Sandwich).</p>
  </blockquote>
  
  <p>I want to use this from Android SDK. So I found this. Android SDK provides this <a href="http://developer.android.com/reference/android/telephony/PhoneNumberUtils.html" rel="noreferrer">PhoneNumberUtils</a>
  .</p>
  
  <p>And there is a function </p>
  
  <blockquote>
    <p>formatNumberToE164(String phoneNumber, String defaultCountryIso)</p>
  </blockquote>
  
  <p>It's really easy to use. but API level of this function is 21.</p>
  
  <p>So My question is..How can I use PhoneNumberUtils to convert phonenumber to E164 under API Level 14(ICS) ~ 21?</p>
  
  <p>Thanks.!</p>