在 android-billing-5.0 中获取 ProductDetails 价格

Getting the ProductDetails price in android-billing-5.0

我已将我的 Kotlin 应用程序从 4.0 升级到 android-billing 5.0,因此,SkuDetails 现已弃用,因此我正在迁移到使用 migration instructions.[=13= 的 ProductDetails ]

之前,我使用 SkuDetails.price, but I cannot find a similar method in ProductDetails 向用户显示应用内购买的购买价格。

在 Google Play Billing Library 5.0 中,是否有未弃用的方法来检索应用内购买或订阅的价格?

基于 documentation you can call getOneTimePurchaseOfferDetails() on ProductDetails to return a ProductDetails.OneTimePurchaseOfferDetails 对象,它有一个 getFormattedPrice() 方法来 return 购买 in-app 的价格。

对于订阅,您可以调用 getSubscriptionOfferDetails(),其中 return 是 ProductDetails.SubscriptionOfferDetails objects, which have a getPricingPhases() method to return different pricing phases. The pricing phase 个对象的列表,有一个 getFormattedPrice() 方法来获取价格。