1

我刚刚编写了一个测试应用程序来测试应用程序购买,它只是一个测试应用程序,你必须按下一个按钮,然后你购买一个“高级”会员资格,这将使该按钮不可见(这只是一个测试应用程序)

所以当我的朋友按下按钮后,他得到了支付屏幕,他支付了,但是当他回到应用程序时,按钮仍然存在

这就是我开始购买的方式

    // User clicked the "Upgrade to Premium" button.
    public void onUpgradeAppButtonClicked(View arg0) {
        Log.d(TAG, "Upgrade button clicked; launching purchase flow for upgrade.");
   //     setWaitScreen(true);
        mHelper.launchPurchaseFlow(this, SKU_PREMIUM, RC_REQUEST,   mPurchaseFinishedListener);
    }

以及购买完成时

// Callback for when a purchase is finished
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
    public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
        Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);

        int duration = Toast.LENGTH_SHORT;
        if (result.isFailure()) {
            // Oh noes!
         //   complain("Error purchasing: " + result);
         //   setWaitScreen(false);
            Toast.makeText(getBaseContext(), "Failed to purchase", duration).show();
            return;
        }

        Log.d(TAG, "Purchase successful.");

        if (purchase.getSku().equals(SKU_PREMIUM)) {
            // bought the premium upgrade!
            Log.d(TAG, "Purchase is premium upgrade. Congratulating user.");
          //  alert("Thank you for upgrading to premium!");
            mIsPremium = true;

            Toast.makeText(getBaseContext(), "You are now premium", duration).show();
            Button test = (Button) findViewById(R.id.test);
            test.setVisibility(View.INVISIBLE);
          //  updateUi();
         //   setWaitScreen(false);
        }
    }
};

代码取自谷歌提供的示例应用程序,我删除了我不需要的部分,也许我删除了一些需要的东西?

4

1 回答 1

2

实际上,您还必须将onActivityResult示例活动中的方法复制到您的活动中。完成此操作后,它应该可以工作。

于 2012-12-25T04:10:51.280 回答