货币根据Android的国家货币、根据、国家、Android

2023-09-06 10:14:59 作者:别再遇我

我希望根据当前GPS位置显示的货币符号。我怎样才能做到这一点?我使用低于code,但它总是$返回。

 列表<地址>地址=地理coder.getFromLocation(纬度,经度,1);地址物镜= addresses.get(0);货币立方厘米= Currency.getInstance(obj.getLocale()); 

解决方案

您使用以下获得象征货币?

  Currency.getInstance(obj.getLocale())getSymbol()。 
有懂的货币的告诉我这是哪国货币

是您obj.getLocale()一个有效的区域设置code以下 ISO_3166-1 并 ISO 639-1 的像de_DE这个。更进一步你放心,你为TestDevice支持所需的语言环境?语言环境的详细信息,这里。

I want to show Currency symbol according to current gps location. How can I do this? I am using below code but it always returns $.

List<Address> addresses = geocoder.getFromLocation(lat, lng, 1);
Address obj = addresses.get(0);
Currency cc=Currency.getInstance(obj.getLocale());

解决方案

Are you using the following to obtain the symbol for currency?

 Currency.getInstance(obj.getLocale()).getSymbol();

Is your obj.getLocale() a valid locale code following ISO_3166-1 and ISO 639-1 like "de_DE". Further more have you assured, that your testdevice supports the required locales? More information for locales here.