querySkuDetails

mail@pastecode.io avatar
unknown
java
a month ago
2.7 kB
2
Indexable
Never
 private void querySkuDetails() {
        SkuDetailsParams.Builder skuDetailsParamsBuilder = SkuDetailsParams.newBuilder();
        ArrayList<String> list = new ArrayList<>();
        list.add(locaspot_weekly);
        list.add(locaspot_monthly);
        list.add(locaspot_threemonth);
        skuDetailsParamsBuilder.setSkusList(list);
        skuDetailsParamsBuilder.setType(BillingClient.SkuType.SUBS);
        billingClient.querySkuDetailsAsync(skuDetailsParamsBuilder.build(), new SkuDetailsResponseListener() {
            @Override
            public void onSkuDetailsResponse(@NonNull @NotNull BillingResult billingResult, @Nullable @org.jetbrains.annotations.Nullable List<SkuDetails> list) {
                if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK){
                    for (SkuDetails skuDetails : list) {
                        mSkuDetailsMap.put(skuDetails.getSku(), skuDetails);
                        Log.d("****** SUB ******",skuDetails.getSku());
                        if(skuDetails.getSku().contains(locaspot_weekly)){
                            runOnUiThread(new Runnable() {
                                public void run() {
                                    weeklyPrice = skuDetails.getOriginalPrice();
                                    subBtn.setText(getString(R.string.weekly) + " | " + weeklyPrice);
                                }
                            });
                            //
                        }else if(skuDetails.getSku().contains(locaspot_monthly)){
                            runOnUiThread(new Runnable() {
                                public void run() {
                                    monthlyPrice = skuDetails.getOriginalPrice();
                                    subBtn2.setText(getString(R.string.monthly) + " | " + monthlyPrice);
                                }
                            });
                            //
                        }else if(skuDetails.getSku().contains(locaspot_threemonth)){
                            runOnUiThread(new Runnable() {
                                public void run() {
                                    threeMonthPrice = skuDetails.getOriginalPrice();
                                    subBtn3.setText(getString(R.string.threemonth) + " | " + threeMonthPrice);
                                }
                            });
                            //
                        }
                        Log.e("****** SUB ******",skuDetails.getOriginalPrice());
                        Log.e("****** SUB ******","----FINISHED----");
                    }
                }
            }
        });
    }
Leave a Comment