在应用程序购买不完全工作

时间:2012-12-21 23:53:48

标签: android

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

所以在我的朋友按下按钮后,他收到付款屏幕,他付了钱,但当他回到应用程序时,按钮仍在那里

这就是我开始购买的方式

    // 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);
        }
    }
};

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

1 个答案:

答案 0 :(得分:2)

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