【问题标题】:PendingIntent returned from getBuyIntent is always null从 getBuyIntent 返回的 PendingIntent 始终为 null
【发布时间】:2016-04-16 14:54:41
【问题描述】:

我正在尝试提供订阅,但我从 getBuyIntent 获得的 PendingIntent 始终为空。虽然,请求购买和项目详细信息有效。

我已经尝试过使用不同的帐户,签名的、可调试的和不可调试的 apk,但还是一样。

Bundle bundle = mService.getBuyIntent(3, getActivity().getPackageName(), sku, "subs", developerPayload);

for (String key : bundle.keySet()) {
    Log.d("SUBSCRIBE: " + key + " = \"" + bundle.get(key) + "\"");
}

PendingIntent pendingIntent = bundle.getParcelable("RESPONSE_BUY_INTENT");

if (bundle.getInt("RESPONSE_CODE") == BILLING_RESPONSE_RESULT_OK) {
    if (pendingIntent != null) {
        // Start purchase flow (this brings up the Google Play UI).
        // Result will be delivered through onActivityResult().
        getActivity().startIntentSenderForResult(pendingIntent.getIntentSender(), RC_BUY, new Intent(),
                Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0));
    } else {
        Log.e("Subscribe", "PendingIntent is null!");
    }
}

这是 logcat 的输出

:订阅:RESPONSE_CODE = "0"
: 订阅: BUY_INTENT = "PendingIntent{b1c5591: android.os.BinderProxy@c48ccf6}"
: 订阅:PendingIntent 为空!

这 (http://developer.android.com/google/play/billing/billing_integrate.html#Subs) 是我遵循的实现,但有一点不同,我的代码放在片段而不是活动中

【问题讨论】:

    标签: android in-app-purchase in-app-billing android-pendingintent subscription


    【解决方案1】:

    零响应代码表示它正在工作,但我认为你的捆绑密钥错误,尝试

    bundle.getParcelable("BUY_INTENT");
    

    【讨论】:

    • 另一个明显的愚蠢的复制粘贴错误 :-) 这不是第一次。太糟糕了,谷歌文档不是维基......但无论如何谢谢!
    猜你喜欢
    • 1970-01-01
    • 2021-09-13
    • 1970-01-01
    • 2016-05-31
    • 2015-08-15
    • 2012-03-18
    • 2016-11-04
    • 2016-07-28
    • 2010-11-08
    相关资源
    最近更新 更多