0

I'm new for android, In my app i have three edittext and one button. If user enter their mobile number and press buttons means automatically country code and country name filled in other edittext.

I used below code

TelephonyManager tm = (TelephonyManager)getActivity().getSystemService(getActivity().TELEPHONY_SERVICE);
String countryCodeValue = tm.getNetworkCountryIso();
Log.d("CountryCOde",countryCodeValue);

But, It not working in without sim(Tablet). So, i want to get country code and name with help of mobile number. Want to work without sim also.

Paolo Forgia
  • 6,572
  • 8
  • 46
  • 58
hikoo
  • 517
  • 4
  • 10
  • 20
  • 1
    How would you like to get information about cellular network without the connection to the network? My advice would be to find another way to get user location, for example from user location or language set in telephone. – R. Zagórski Aug 29 '16 at 07:27
  • Then how tablet user using app.. I want to allow particular country – hikoo Aug 29 '16 at 07:33
  • Then choose the way to get current user location. There are API's that show the country, when passing IP address. And block the user if he is in disallowed country. – R. Zagórski Aug 29 '16 at 07:38
  • If i Use this: getActivity().getResources().getConfiguration().locale.getCountry(); It return US – hikoo Aug 29 '16 at 07:52
  • Because you have `en-US` locale set in the phone. Try an approach with user location. – R. Zagórski Aug 29 '16 at 07:53
  • Check this out. This might help you. [Click](http://stackoverflow.com/questions/16809508/extract-code-country-from-phone-number-libphonenumber) – Salman Shaikh Aug 29 '16 at 08:48
  • How to get country name from ip address – hikoo Aug 29 '16 at 11:35

0 Answers0