I have used PhoneNumberUtil as a tool for converting a phone number to international. However, if a user input is a local phone number which the app doesn't know what country the local phone number is from. How can you determine its country code.
My Code.
String phoneNumberParse = phoneNumberTextInput.getText().toString();
PhoneNumberUtil phoneUtil = PhoneNumberUtil.getInstance();
try {
Phonenumber.PhoneNumber convertedPhoneNumber = phoneUtil.parse(phoneNumberParse, null);
newPhoneNumber = phoneUtil.format(convertedPhoneNumber, PhoneNumberUtil.PhoneNumberFormat.E164);
Toast.makeText(getActivity(), newPhoneNumber, Toast.LENGTH_SHORT).show();
} catch (NumberParseException e) {
System.out.print("Phone Util"+e);
}