应用内结算mHelper.dispose()错误 [英] in-app billing mHelper.dispose() error

查看:80
本文介绍了应用内结算mHelper.dispose()错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试实施应用内结算.

I'm tryng to implement in-app-billing.

当我按照本教程并将以下行添加到我的应用程序中时:

When i follow the tutorial and add the lines bellow to my app:

 public void onDestroy() {
        super.onDestroy();
        if (mHelper != null) mHelper.dispose();
        mHelper = null;

我收到以下错误:

Error:(216, 45) error: unreported exception IabAsyncInProgressException; must be caught or declared to be thrown

奇怪的是,当我将mHelper.dispose()替换为mHelper.disposeWhenFinished()时,它起作用了.

The strange thing is when i replace mHelper.dispose() for mHelper.disposeWhenFinished() it works.

我担心会导致同一错误再次出现在

I'm worried cause the same error appears again in

mHelper.launchPurchaseFlow(this,ITEM_SKU,1001,mPurchaseFinishedListener,hpacote);

谢谢

推荐答案

是的,我在此方面也浪费了很多时间,因为在 https://下载TrivialDrive具有正确更正的github.com/googlesamples/android-play-billing/tree/master/TrivialDrive .

Yes, i'm also waste a lot of time in this because in the Google Tutorial on https://developer.android.com/training/in-app-billing/preparing-iab-app.html the sample is old and buggy. If you want a right sample you have to download TrivialDrive from github https://github.com/googlesamples/android-play-billing/tree/master/TrivialDrive that has right corrections.

从TrivialDrive MainActivity:

From TrivialDrive MainActivity:

try {
         mHelper.launchPurchaseFlow(this, mSelectedSubscriptionPeriod, IabHelper.ITEM_TYPE_SUBS,oldSkus, RC_REQUEST, mPurchaseFinishedListener, payload);
     } catch (IabAsyncInProgressException e) {
            complain("Error launching purchase flow. Another async operation in progress.");
            setWaitScreen(false);
     }

这是onDestroy()

and this is the onDestroy()

    @Override
    public void onDestroy() {
    super.onDestroy();

    // very important:
    Log.d(TAG, "Destroying helper.");
    if (mHelper != null) {
        mHelper.disposeWhenFinished();
        mHelper = null;
    }
}

我已正确实现了! ;)

i've implemented this without error! ;)

这篇关于应用内结算mHelper.dispose()错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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