2

I am building an app that makes use of phone numbers. I would like to have a user select a country and then based on that country prepend the country code to their phone number. Is there a standard way for doing this in android? I thought the answer was Place AutoComplete, an android service for adding places, but that does not seem to be the answer; at least I can't get the country code from that service as explained on The Google Developer Academy site.

Does anyone know how I might get this done?

Katedral Pillon
  • 14,534
  • 25
  • 99
  • 199
  • edited to remove hold – Katedral Pillon Apr 09 '14 at 00:32
  • http://stackoverflow.com/questions/5402253/getting-telephone-country-code-with-android?lq=1 – Konsol Labapen Apr 09 '14 at 19:39
  • That link is not completely bad, but it is lacking a lot. I need full country name(s) not just abbreviations. So perhaps I can hardcode this myself, but oh boy the possibility for error is so great. As for using the network country (`manager.getNetworkCountryIso()`), the device may not be a phone. So imagine user using a tablet/pad but owns a valid phone number on another device. User may be using pad in US while phone number is for Haiti or France or who knows? I will rack my brain against the answer in that link, but please, if someone has already solved this problem: help. – Katedral Pillon Apr 09 '14 at 20:09

1 Answers1

0

You can use this library by google for handling phone numbers on android. You will need to send the country code once the user selects and then use the PhoneNumberUtil.getInstance().parse(,)

Karthik
  • 934
  • 9
  • 21