IabHelper PurchaseFinishedListener [英] IabHelper PurchaseFinishedListener

查看:260
本文介绍了IabHelper PurchaseFinishedListener的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我通过标准发出购买意向

If I send a purchase intent via the standard

String mySku = "android.test.purchased";

mHelper.launchPurchaseFlow(this, mySku, 10001, mPurchaseFinishedListener);

我可以购买该项目,它将存储和我可以查询的项目和工作正常了。不工作的唯一的东西是PurchaseFinishedListener。我知道了codeD pretty的很多相同的示例应用程序但它似乎并没有被调用的。

I am able to purchase the item and it will store and I can query the item and that works fine too. The only thing that doesn't work is is the PurchaseFinishedListener. I've got it coded pretty much identical to the sample app however it doesn't seem to get called at all.

12-12 01:40:47.248: D/IabHelper(23502): Calling getPurchases with continuation token: null
12-12 01:40:50.116: D/IabHelper(23502): Starting async operation: launchPurchaseFlow

这些是最后两种方法被调用后,当我完成了购买它不叫purchasefinishedlistener

These are the last two methods that get called and after that when I finish the purchase it doesn't call the purchasefinishedlistener

IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new OnIabPurchaseFinishedListener() {

    @Override
    public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
        Log.d(TAG, "Purchase finished: " + result + ", purchase: "
                + purchase);
        if (result.isFailure()) {
            complain("Error purchasing: " + result);
            // setWaitScreen(false);
            return;
        }

        if (purchase.getSku().equals(mySku)) {
            Log.d(TAG, "mySku is being consumed.");
            mHelper.consumeAsync(purchase, mConsumeFinishedListener);
        }
        Log.d(TAG, "Purchase successful.");
        new AsyncQuestionsActivity().doInBackground();
    }
};

从日志到最后的作品没有。有什么,我只是莫名其妙地失踪了?

Nothing from the log to the end works. Is there anything that I'm just somehow missing?

推荐答案

我发现了如何解决它。在onActivityResult实施handleActivityResult。它需要创造的监听器和启动采购流程之间的桥梁。

I found out how to fix it. Implement handleActivityResult in onActivityResult. It's needed to create a bridge between the listener and the launched purchase flow.

下面给出的是code我用:

Given below is the code I used:

@Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + ","
                + data);

        // Pass on the activity result to the helper for handling
        if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
            super.onActivityResult(requestCode, resultCode, data);
        } else {
            Log.d(TAG, "onActivityResult handled by IABUtil.");
        }
    }

这篇关于IabHelper PurchaseFinishedListener的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆