gpt4 book ai didi

android - 永远不会调用 Google InAppBilling onPurchaseStateChange

转载 作者:太空宇宙 更新时间:2023-11-03 12:42:30 24 4
gpt4 key购买 nike

永远不会调用回调方法 onPurchaseStateChange。我做了自己的演示应用程序,还尝试使用谷歌提供的演示(地下城)。

我从 onClick 方法调用 requestPurchase(String productId, String payload)


@Override
public void onClick(View view) {
if(view == requestPurchaseButton) {
mBillingService.requestPurchase("android.test.purchased", "10");
}
}

调用回调方法onRequestPurchaseResponse(Request, ResponseCode)。此处的 responseCode 给出了值 RESULT_OK。所以请求已经发送到服务器。


@Override
public void onRequestPurchaseResponse(RequestPurchase request,
ResponseCode responseCode)
{
if(responseCode == ResponseCode.RESULT_OK) {
Log.d("AJ", "onRequestPurchaseResponse.ResponeCode.RESULT_OK");
textView.append(request.mProductId + "\n");
} else if(responseCode == ResponseCode.RESULT_USER_CANCELED) {
//doesn't go here
} else {
//doesn't go here
}
}

此方法的 javadoc 说明

This is called when we receive a response code from Market for a RequestPurchase request that we made. This is NOT used for any purchase state changes. All purchase state changes are received in onPurchaseStateChange(PurchaseState, String, int, long). This is used for reporting various errors, or if the user backed out and didn't purchase the item. The possible response codes are: RESULT_OK means that the order was sent successfully to the server. The onPurchaseStateChange() will be invoked later (with a purchase state of PURCHASED or CANCELED) when the order is charged or canceled. This response code can also happen if an order for a Market-managed item was already sent to the server. RESULT_USER_CANCELED means that the user didn't buy the item. RESULT_SERVICE_UNAVAILABLE means that we couldn't connect to the Android Market server (for example if the data connection is down). RESULT_BILLING_UNAVAILABLE means that in-app billing is not supported yet. RESULT_ITEM_UNAVAILABLE means that the item this app offered for sale does not exist (or is not published) in the server-side catalog. RESULT_ERROR is used for any other errors (such as a server error).

但是回调方法


@Override
public void onPurchaseStateChange(PurchaseState purchaseState,
String itemId, int quantity, long purchaseTime,
String developerPayload) {
Log.d("AJ", "onPurchaseStateChanged");

}

永远不会被调用。

我错过了什么吗?在 Dungeons 中正在做同样的事情(Google 提供的演示)并且 onPurchaseStateChange 没有被调用。

Test-InAppBilling文件显示我们必须能够达到 Purchased 状态。但是当我尝试时,我只看到

android.test.purchased: sending purchase request.

最佳答案

我遇到了同样的问题,但我自己解决了。我在代码中使用我工作的公钥,但试图在我的个人手机上运行该应用程序。由于我是使用个人帐户在手机上登录的,所以我猜谷歌正确地认为我不是开发者。我认为他们会发回一条错误消息。将我的个人 key 插入代码后,它在我的手机上运行良好。因此 key 可能也不适合您。

关于android - 永远不会调用 Google InAppBilling onPurchaseStateChange,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5429345/

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