gpt4 book ai didi

java - 您在哪里恢复用户的应用内购买?

转载 作者:太空宇宙 更新时间:2023-11-03 11:02:51 25 4
gpt4 key购买 nike

我一直在关注垃圾谷歌教程,但它没有提到在哪里放置代码来恢复用户购买。在 TD 教程中它写道:

try {
mHelper.queryInventoryAsync(mGotInventoryListener);
} catch (IabAsyncInProgressException e) {
complain("Error querying inventory. Another async operation in progress.");
}

startSetup()方法中,这是我写的,放在哪里?

最佳答案

您可以在应用中的任何位置检索有关用户购买的信息。

Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
int response = ownedItems.getInt("RESPONSE_CODE");
if (response == 0) {
ArrayList<String> ownedSkus =
ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");
ArrayList<String> purchaseDataList =
ownedItems.getStringArrayList("INAPP_PURCHASE_DATA_LIST");
ArrayList<String> signatureList =
ownedItems.getStringArrayList("INAPP_DATA_SIGNATURE_LIST");
String continuationToken =
ownedItems.getString("INAPP_CONTINUATION_TOKEN");

for (int i = 0; i < purchaseDataList.size(); ++i) {
String purchaseData = purchaseDataList.get(i);
String signature = signatureList.get(i);
String sku = ownedSkus.get(i);

// do something with this purchase information
// e.g. display the updated list of products owned by user
}

// if continuationToken != null, call getPurchases again
// and pass in the token to retrieve more items
}

您可以在任何想要恢复用户购买的地方使用此代码

关于java - 您在哪里恢复用户的应用内购买?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38341492/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com