android - 从 getBuyIntent 返回的 PendingIntent 始终为空

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

我正在尝试提供订阅,但我从 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 输出

: SUBSCRIBE: RESPONSE_CODE = "0"
: SUBSCRIBE: BUY_INTENT = "PendingIntent{b1c5591: android.os.BinderProxy@c48ccf6}"
: Subscribe: PendingIntent is null!

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

最佳答案

零响应代码表示它正在工作,但我认为您的 bundle key 错误,请尝试

bundle.getParcelable("BUY_INTENT");

关于android - 从 getBuyIntent 返回的 PendingIntent 始终为空,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36665674/

相关文章:

java - 在Java对象中接收JSON数据

android - 在 Android volley 库中使用 cookie

java - 了解 Android 紧密循环/自旋挂起错误

ios - 检查用户在应用内购买中购买的产品

ios - 应用内购买后检查用户是否付款的最佳方法是什么

Android 应用内结算订阅状态更改回调

java - 在 Android 中压缩图像以上传到服务器的过程

android inapp 以本地货币购买产品价格

android应用内购买导致分发限制

java - 在 Android 中取消应用内计费订阅