这可能是由于缓存问题导致的,可以尝试清除Google Play Store应用程序的缓存和数据。如果清除缓存和数据后仍然存在问题,则可以尝试以下步骤:
private val skuList = listOf("product_id_1", "product_id_2")
val params = SkuDetailsParams.newBuilder()
.setType(BillingClient.SkuType.INAPP)
.setSkusList(skuList)
.build()
billingClient.querySkuDetailsAsync(params) { billingResult, skuDetailsList ->
// Handle the result
}
private lateinit var billingClient: BillingClient
override fun onPurchasesUpdated(billingResult: BillingResult, purchases: MutableList?) {
// Handle the result
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
billingClient = BillingClient.newBuilder(this)
.setListener(this)
.enablePendingPurchases()
.build()
billingClient.startConnection(object : BillingClientStateListener {
override fun onBillingSetupFinished(billingResult: BillingResult) {
// Handle the result
}
override fun onBillingServiceDisconnected() {}
})
}
override fun onBillingSetupFinished(billingResult: BillingResult) {
if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
// The billing client is connected successfully
} else {
// Handle the error
}
}
override fun onPurchasesUpdated(billingResult: BillingResult, purchases: MutableList?) {
if (billingResult.responseCode == BillingClient.BillingResponseCode.OK
&& purchases != null) {
for (purchase in purchases) {
if (purchase.purchaseState == Purchase.PurchaseState.PURCHASED) {
// Handle the completed purchase