what is the best and fastest way to get the country iso code by starting an App build with phonegap? There is a function to get the geo coordinates, but not the Iso code. For getting the iso code maybe it is necessary to call an external webservice and get the iso by given coordinates. Is there a simplest way?
Thanks Nik
I found navigator.language sometimes only gave me the language and not the locale (eg "en" rather than "en-gb"). To solve this in android I created a new java class in src/com called DeviceCulture.java with this code:
package com;
import java.util.Locale;
public class DeviceCulture {
public String get() {
try{
return Locale.getDefault().toString();//get the locale from the Android Device
}catch(Exception e){
return "";
}
}
}
Then add this before the super.loadUrl line in /src/com/phonegap/YOUR_APP/App.java
DeviceCulture deviceCulture = new DeviceCulture();
appView.addJavascriptInterface(deviceCulture , "DeviceCulture");
Then in your javascript use this to get the locale (eg "en_GB")
window.DeviceCulture.get();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With