如何使用Firebase Phone Auth在Android中将电话号码提供商的国家代码(如+44)转换为字符串?

问题描述:

请帮助我使用Firebase电话身份验证将国家代码转换为字符串。如何使用Firebase Phone Auth在Android中将电话号码提供商的国家代码(如+44)转换为字符串?

+0

嗨GreatLeaner,你找到任何解决方案?我被困在这里.. –

您可以使用Firebase for Android中存在的PhoneNumberUtils类的内部方法。

TelephonyManager tm = (TelephonyManager)getActivity().getSystemService(getActivity().TELEPHONY_SERVICE); 
String countryCodeValue = tm.getNetworkCountryIso(); 
Log.d(TAG, "Countrycode: " + PhoneNumberUtils.getCountryCode(countryCodeValue));