发布于 2017-09-28 22:18:07
您应该只对结果列表中的项使用查询SKU详细信息并使用getIntroductoryPrice()方法。
它最近被添加到1.0版本中。因此,如果您在发布后的第一天就得到了库,那么您应该使用清除分级缓存和/build文件夹重新下载更新版本。
发布于 2017-09-27 02:21:59
是的,有。请看这个>> https://codelabs.developers.google.com/codelabs/play-billing-codelab/#1
val skuList = arrayListOf("sku_id_of_in_app_product","sku_id_of_in_app_product")
val itemType = SkuType.INAPP // or SkuType.SUBS that corresponds with the skuList
val skuDetailsParams = SkuDetailsParams.newBuilder().setSkusList(skuList).setType(itemType).build()
mBillingClient.querySkuDetailsAsync(skuDetailsParams, object : SkuDetailsResponseListener{
override fun onSkuDetailsResponse(responseCode: Int, skuDetailsList: MutableList<SkuDetails>?) {
responseListener.onSkuDetailsResponse(responseCode, skuDetailsList);
}
})您的侦听器:您需要使用侦听器,以便在异步查询完成时能够获得响应!
val responseListener = SkuDetailsResponseListener { responseCode, skuDetailsList ->
if (responseCode == BillingClient.BillingResponse.OK && skuDetailsList != null) {
val inList = ArrayList<SkuRowData>()
for (details in skuDetailsList) {
Log.i(TAG, "Found sku: $details")
inList.add(SkuRowData(details.sku, details.title, details.price, details.introductoryPrice, details.description, details.type))
}
}
}SkuRowData只是一个模型类
class SkuRowData(sku: String?, title: String?, price: String?, introductory_price: String?, description: String?, type: String?)请注意,您只能在应用程序产品中获得订阅的介绍性价格!
https://stackoverflow.com/questions/46033802
复制相似问题