Skip to main content
Legend
July 29, 2013
Answered

How can I read current country from device in iOS and Android?

  • July 29, 2013
  • 1 reply
  • 5609 views

See subject!

I am trying to read the current country from both iPad and Android tablet.

I know that in iOS, it can be obtained here:

- (NSString*)getCurrentCountryFromUserLocale

{

    NSLocale *userLocale = [NSLocale currentLocale];

    NSString *countryCode = [userLocale objectForKey:NSLocaleCountryCode];

    return countryCode;

}

But that, surely, will require me to build an ANE? There must be a way to do that without needing custom code?

For Android, I'm even more clueless!

Any clues greatly appreciated, thanks.
G

UPDATE:

Android may be readable via this:

http://stackoverflow.com/questions/11293642/how-can-i-get-my-android-device-country-code-without-using-gps

But still think there should be something in the Flex / AIR SDK?

This topic has been closed for replies.
Correct answer jano_alex_es

You can use

new StringTools(LocaleID.DEFAULT).actualLocaleIDName

It returns locale. (en-GB for example)

1 reply

jano_alex_esCorrect answer
Inspiring
July 29, 2013

You can use

new StringTools(LocaleID.DEFAULT).actualLocaleIDName

It returns locale. (en-GB for example)

Legend
July 29, 2013

Thanks, works like a dream.

G