从getBuyIntent返回的PendingIntent始终为null

时间:2016-04-16 14:54:41

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

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

我已尝试使用不同的帐户,签名,可调试和不可调试的apks,但仍然相同。

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输出

  

:SUBSCRIBE:RESPONSE_CODE =“0”
  :SUBSCRIBE:BUY_INTENT =“PendingIntent {b1c5591:android.os.BinderProxy@c48ccf6}”

  :订阅:PendingIntent为null!

这个(http://developer.android.com/google/play/billing/billing_integrate.html#Subs)是我遵循的实现,差别很小,我的代码放在一个片段而不是一个Activity

1 个答案:

答案 0 :(得分:2)

零响应代码表示它正在运行,但是您的捆绑密钥错误,我想,请尝试

bundle.getParcelable("BUY_INTENT");