我想获得经度和纬度我使用这种方法并且工作正常但是当我将手机语言改为波斯语时它不起作用。
lattude = location.convert(location.getLatitude(), location.FORMAT_SECONDS);
lattude = replaceDelimiters(lattude, decimalPlace);
char lonCardinal = location.getLatitude() >= 0 ? 'N' : 'S';
lattude = lattude + " " + lonCardinal;
txt5.setText(lattude);
十进制方法:
@NonNull
private String replaceDelimiters( String str, int decimalPlace) {
str = str.replaceFirst(":", "°");
str = str.replaceFirst(":", "'");
int pointIndex = str.indexOf(".");
int endIndex = pointIndex + 1 + decimalPlace;
if (endIndex < str.length()) {
str = str.substring(0, endIndex);
}
str = str + "\"";
return str;
}