国际或本地的Android格式化电话号码

时间:2016-03-18 09:56:43

标签: android

我想转换我的电话号码以符合国际或本地格式。但是使用默认的本地格式类型使用PhoneNumberUtils.formatNumber()。不能给出理想的结果。

  

formattingType =   PhoneNumberUtils.getFormatTypeForLocale(Locale.getDefault());   PhoneNumberUtils.formatNumber(editable,formattingType);

例如:

input         -> expected result    -> actual result    
0212345678     -> 02 1234 5678      -> 021-234-5678
0912345678     -> 0912 345 678      -> 091-234-5678
+886912345678  -> +886 912 345 678  -> +886912345678
+18055673802   -> +1 805-567-3802   -> +18055673802

预期结果从Native拨号程序呼叫日志中引用。

任何人都可以给出一些建议,如何根据国家代码和本地号码获得预期结果。

0 个答案:

没有答案