BillingClient 总是 returns SERVICE_DISCONNECTED
BillingClient always returns SERVICE_DISCONNECTED
所以我有一个用
实例化的计费客户端
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 ");
}
});
无论出于何种原因,timber 线上的断点总是 returns 断开连接。任何人都可以提供见解或示例来说明我将如何执行此操作吗?
事实证明,我使用的 apk 版本没有使用正确的版本编号等进行签名。一旦我确定我能够连接到播放服务并弄清楚我想要什么。
我遇到了这个问题。
也一定要开启连接:
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.
}
});
如果您使用自定义 rom 或 root 设备,它可能无法工作。
Run a system image on which the Google Play client application is preinstalled.
If Google Play is not preinstalled in the system image, your application won't be able to communicate with the Google Play licensing server.
https://developer.android.com/google/play/licensing/setting-up
所以我有一个用
实例化的计费客户端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 ");
}
});
无论出于何种原因,timber 线上的断点总是 returns 断开连接。任何人都可以提供见解或示例来说明我将如何执行此操作吗?
事实证明,我使用的 apk 版本没有使用正确的版本编号等进行签名。一旦我确定我能够连接到播放服务并弄清楚我想要什么。
我遇到了这个问题。 也一定要开启连接:
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.
}
});
如果您使用自定义 rom 或 root 设备,它可能无法工作。
Run a system image on which the Google Play client application is preinstalled. If Google Play is not preinstalled in the system image, your application won't be able to communicate with the Google Play licensing server.
https://developer.android.com/google/play/licensing/setting-up