本文介绍了Android应用内购买:如何消费?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在自己的应用中实现了Google In-App Billing V3,并且进行了首次测试购买.现在,看到我想要使用它,但是如果我再次单击购买"按钮,则会收到错误消息,我想知道如何以及在何处插入"consumPurchase".我整天都在计算机上搜索每个线程,但是我一直对该版本的旧版本感到困惑.从我看到的情况来看,在成功购买商品之后以及创建活动时,我需要调用ConsumerPurchase,但是我不知道该怎么做.

I've implemented Google In-App Billing V3 in my app and i did my first test purchase. Now, as seen that i want it consumable, but if i click the "Purchase" button again i receive an error, i'm wondering how and where to insert "consumePurchase". I've been all day long on my computer searching on every thread, but i'm making confusion with old versions of the same. From what i saw, i need to call consumePurchase after the successfully purchased item AND when the activity is created, but i can't figure out how to do it.

这是唯一的一行代码吗?

Is this the one and only line of code?

int response = mService.consumePurchase(3, getPackageName(), token);

如果是,什么是令牌"?

If so, what is "token"?

P.s.消耗品有:50、150和300个硬币,用户可以购买以在游戏中发挥一些优势.

P.s. the consumable items are: 50, 150 and 300 coins that the user can buy to take a little advantage in the game.

Aaah,让我困惑:/

Aaah, so confusing for me :/

推荐答案

如官方文档中所述: https://developer.android.com/google/play/billing/billing_reference.html

购买的响应意图包括多个字段,其中之一是:

The response intent to the purchase includes several fields, one of them being:

在JSON内,您有几个字段(也在该页面中进行了说明),您正在寻找的字段是:

Inside that JSON, you have several fields, also explained in that page, the one you are looking for is:

从官方示例应用程序可以很容易地遵循所有这些规则,我建议您下载并试用该示例应用程序,并检查代码.

All these is quite easy to follow from the official sample application, which I recommend you to download and try out, also to check the code.

这篇关于Android应用内购买:如何消费?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-23 07:06