是否有一种公共算法可以格式化德国电话号码(手机和固定电话)?我看到有一种格式化电话号码的方法 PhoneNumberUtils.getFormatTypeForLocale(Locale locale)
但这仅适用于 NANP 国家,参见此处。
is there a public algorithm that formats German phone numbers (mobile and landlines)? I saw there is a method to format phone numbers PhoneNumberUtils.getFormatTypeForLocale(Locale locale)
but this is only for NANP countries, see here.
发布评论
评论(2)
也许 libphonenumber 可以做你想做的事?
Maybe libphonenumber can do what you want?
就像大多数 Android 文档 PhoneNumberUtils 的创建非常糟糕。尝试 Locale.GERMANY 作为方法输入。如果像您提到的那样区域设置格式不可用,您必须编写自己的方法。也许扩展 PhoneNumberUtils 并覆盖该方法是一个很好的做法。无论如何,祝你好运:)。
编辑:阿斯巴甜的答案对我来说似乎更合乎逻辑。
Like most android documentation PhoneNumberUtils very poorly created. Try Locale.GERMANY as method input. If the locale format is unavaible like you mentioned, you have to write your own method. Maybe extending PhoneNumberUtils and overriding that method is a good practice. Good luck anyway :).
Edit: aspartame's answer seems more logical to me.