I use Play Billing Library
and I have two subscriptions
for one and three months. For a 3
month subscription, I want to display the price for 1
month.
For example, a 1
month subscription is $1,50
and a 3
month subscription is $3
($1
for a 1
month). But I have some problems with currencies.
This is a code:
long priceAmountMicros = skuDetails.getPriceAmountMicros(); //3000000
String priceCurrency = skuDetails.getPriceCurrencyCode(); //USD
float priceFloat = (float)priceAmountMicros / 3 / 1000000; //1
String price = new DecimalFormat("#0.00").format(priceFloat);
Currency currency = Currency.getInstance(priceCurrency);
String symbolCurrency = currency.getSymbol();//$
textView.setText(price + " " + symbolCurrency); //1.00 $ or 70.00 руб
The code almost is working. USD converted to $. EUR converted to £ and others. There are some problems with some currencies, for example, the Russian currency does not work. RUB converted to руб, but I expect ₽
There is a standard method for getting the price:
String price = skuDetails.getPrice();//3 $ or 210 ₽
Am I doing something wrong? Could you help me please?
You can use Currency class from java.util package
Currency.getInstance(sku.priceCurrencyCode).symbol
will give you the symbol for currency code
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