如何正确使用querySkuDetailsAsync?
How to correctly use querySkuDetailsAsync?
我正在尝试使用计费库,并且我正在从官方 Android 开发者网站 here 获取信息。但是我发现了很多麻烦。主要是编译问题。看起来该文档未完成。当我开始一步一步地进行时,我不得不搜索很多额外的信息。现在我一直在尝试执行 querySkuDetailsAsync()
这是我的代码:
billingClient = BillingClient.newBuilder(this).enablePendingPurchases().setListener(this).build();
billingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(BillingResult billingResult) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
// The BillingClient is ready. You can query purchases here.
List<String> skuList = new ArrayList<> ();
skuList.add("sp_hide_ads_year_01");
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(BillingClient.SkuType.SUBS);
billingClient.querySkuDetailsAsync(params.build(),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList) {
//*** I want to Continue here ***
}
});
}
}
@Override
public void onBillingServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});
编译器(Android Studio)说:
'onSkuDetailsResponse(BillingResult, List)' in 'Anonymous
class derived from
com.android.billingclient.api.SkuDetailsResponseListener' clashes with
'onSkuDetailsResponse(BillingResult, List)' in
'com.android.billingclient.api.SkuDetailsResponseListener'; both
methods have erasure, yet neither overrides the other
我不知道这是什么意思。有什么帮助吗?
顺便说一句,我用
implementation 'com.android.billingclient:billing:2.1.0'
我改了行:
public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList)
对于这个,所有编译的东西:
public void onSkuDetailsResponse(BillingResult billingResult, List<com.android.billingclient.api.SkuDetails> skuDetailsList)
我正在尝试使用计费库,并且我正在从官方 Android 开发者网站 here 获取信息。但是我发现了很多麻烦。主要是编译问题。看起来该文档未完成。当我开始一步一步地进行时,我不得不搜索很多额外的信息。现在我一直在尝试执行 querySkuDetailsAsync() 这是我的代码:
billingClient = BillingClient.newBuilder(this).enablePendingPurchases().setListener(this).build();
billingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(BillingResult billingResult) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
// The BillingClient is ready. You can query purchases here.
List<String> skuList = new ArrayList<> ();
skuList.add("sp_hide_ads_year_01");
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(BillingClient.SkuType.SUBS);
billingClient.querySkuDetailsAsync(params.build(),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList) {
//*** I want to Continue here ***
}
});
}
}
@Override
public void onBillingServiceDisconnected() {
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});
编译器(Android Studio)说:
'onSkuDetailsResponse(BillingResult, List)' in 'Anonymous class derived from com.android.billingclient.api.SkuDetailsResponseListener' clashes with 'onSkuDetailsResponse(BillingResult, List)' in 'com.android.billingclient.api.SkuDetailsResponseListener'; both methods have erasure, yet neither overrides the other
我不知道这是什么意思。有什么帮助吗?
顺便说一句,我用
implementation 'com.android.billingclient:billing:2.1.0'
我改了行:
public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList)
对于这个,所有编译的东西:
public void onSkuDetailsResponse(BillingResult billingResult, List<com.android.billingclient.api.SkuDetails> skuDetailsList)