15

所以我有一个计费客户端,我用它来实例化

billingClient = BillingClient.newBuilder(this).setListener(this).build();

然后我打电话

billingClient.startConnection(new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(int responseCode) {
            //TODO: use this for stuff
            com.android.billingclient.api.Purchase.PurchasesResult result;
result = billingClient.queryPurchases(BillingClient.SkuType.SUBS);
    Timber.d(result.toString());

        }

        @Override
        public void onBillingServiceDisconnected() {
            //TODO: use this for stuff
            Timber.d("something went wrong ");
        }
    });

无论出于何种原因,木材线上的断点总是断开连接。谁能提供我将如何做到这一点的见解或示例?

4

3 回答 3

4

我遇到了这个问题。还要确保启动连接:

mBillingClient = BillingClient.newBuilder(mContext).setListener(purchasesUpdatedListener).build();

        mBillingClient.startConnection(new BillingClientStateListener() {
            @Override
            public void onBillingSetupFinished(@BillingClient.BillingResponse int billingResponseCode) {
                if (billingResponseCode == BillingClient.BillingResponse.OK) {

                    Log.d(TAG, "onBillingSetupFinished: BillingClient.BillingResponse.OK ");

                }


            }
            @Override
            public void onBillingServiceDisconnected() {
                // Try to restart the connection on the next request to
                // Google Play by calling the startConnection() method.
            }


        });
于 2018-11-03T13:07:53.443 回答
1

原来我没有使用我的 apk 版本,该版本使用正确的版本编号等签名。一旦我解决了这个问题,我就可以连接到播放服务并弄清楚我想要什么。

于 2018-05-23T18:27:44.937 回答
0

如果您使用自定义 rom 或 root 设备,它可能无法正常工作。

运行预安装了 Google Play 客户端应用程序的系统映像。如果系统映像中未预装Google Play ,您的应用程序将无法与 Google Play 许可服务器通信。

https://developer.android.com/google/play/licensing/setting-up

于 2021-12-05T14:28:26.113 回答