Does anyone know of a quick/easy way to determine what country the user of a MIDlet is in? I've come across a few System.getProperty() ones, but these all seem to return null. Is there any way to do this, other than asking?
Does anyone know of a quick/easy way to determine what country the user of a MIDlet is in? I've come across a few System.getProperty() ones, but these all seem to return null. Is there any way to do this, other than asking?
Have you tried the "microedition.locale" property? You could try using that and, if null, query the user to make him manually input its locale.
Pit
Yes, I tried that property. On my phone it just returns "en" for the language code and nothing for location. Does it ever return the country code?
The only "reliable" way would be to find the mcc of the network provider. Unfortunately there is no access to that information from MIDlets.
I think asking the user would be the most reliable way. You could only ask when you see that the time zone has changed (although you will miss some country changes that way for sure in Europe)...
Hartti
In addition to locale, your best bet for determining the user's country using the MIDP APIs would probably be making a guess based on country code of the smsc. At least in my experience, the smsc country code seems to be same as the country code of the phone number associated with the SIM. Probably there are exceptions though and this technique of course just determines the SIM's home country, not user's current country, when roaming.
The smsc system property (wireless.messaging.sms.smsc) seems to be available on S40 and S60 phones, and also several of other manufacturers' phones - see http://devices.j2mepolish.org/intera...nfoindex.faces