小编Mau*_*k J的帖子

InApp购买RESTORE_TRANSACTIONS,我无法找出代码

我在我的编码中添加了一个应用内购买,它在购买时运行良好,但是当我尝试在删除应用程序并再次安装时添加Restore_Transaction代码时出现错误并关闭应用程序,我在下面添加了编码

在onCreate我写道

startService(new Intent(mContext, BillingService.class));
        BillingHelper.setCompletedHandler(mTransactionHandler);

        if (BillingHelper.isBillingSupported()) {
            BillingHelper.restoreTransactionInformation(BillingSecurity
                    .generateNonce());
        }
Run Code Online (Sandbox Code Playgroud)

然后我叫处理程序使用

public Handler mTransactionHandler = new Handler() {
        public void handleMessage(android.os.Message msg) {
            if (BillingHelper.latestPurchase.isPurchased()) {
                showItem();
            }
        };
    };

    private void showItem() {
        purchased = Purchased.getPurchaseInfo(getApplicationContext());
        if (purchased == null) {
            Date d = new Date();
            Toast.makeText(getApplicationContext(), "--- Upgrated ---",
                    Toast.LENGTH_LONG).show();
            purchased = new Purchased(getApplicationContext());
            purchased.isPurchased = 1;
            purchased.purchasedDate = d.getTime();
            purchased.save();
            Intent intent = new Intent(ActorGenieActivity.this,
                    SplashScreen.class);
            startActivity(intent);
        }
    }
Run Code Online (Sandbox Code Playgroud)

android in-app-purchase

11
推荐指数
1
解决办法
922
查看次数

标签 统计

android ×1

in-app-purchase ×1