У меня есть 3 подписки: plana, planb, planc.
Каждая из них имеет 7-дневную бесплатную пробную версию и базовый план (начинающийся после пробного периода). p>
Мое приложение должно отображать цены на все три плана в соответствующем текстовом представлении (tv_priceplana, tv_priceplanb, tv_priceplanc), но отображает только первый из них (см. ниже). scrrenshots)
Что я получу в лучшем случае:
(что я получу)
Что я хочу:
(то, что я хочу)
Ниже приведена часть кода, показывающая детали планов.
Я не хочу Не понимаю, почему это работает только для деталей первого плана подписки (см. скриншот выше), а не для hte другие.
Я пытался переместить часть if (см. комментарий в коде) в разные места, но в лучшем случае это дает мне этапы первого плана (бесплатная пробная версия и базовый план), но а не другие. Что не так? Какой правильный код для этого?
Обратите внимание, что я также пытался очистить кеш и данные, и учтите, что я хочу сохранить свои textViews (а не переработчик) только для своих трех планы. А для информации я использую биллинговую версию 7.1.1
Заранее спасибо за помощь.
private void getSubsDetails(){
billingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(@NonNull BillingResult billingResult) {
if(billingResult.getResponseCode()== BillingClient.BillingResponseCode.OK){
ImmutableList productList = ImmutableList.of(
// Plan A //
QueryProductDetailsParams.Product.newBuilder()
.setProductId(productIdPlanA)
.setProductType(BillingClient.ProductType.SUBS)
.build(),
// Plan B //
QueryProductDetailsParams.Product.newBuilder()
.setProductId(productIdPlanB)
.setProductType(BillingClient.ProductType.SUBS)
.build(),
// Plan C //
QueryProductDetailsParams.Product.newBuilder()
.setProductId(productIdPlanC)
.setProductType(BillingClient.ProductType.SUBS)
.build()
);
QueryProductDetailsParams queryProductDetailsParams = QueryProductDetailsParams.newBuilder()
.setProductList(productList)
.build();
billingClient.queryProductDetailsAsync(queryProductDetailsParams, new ProductDetailsResponseListener() {
@Override
public void onProductDetailsResponse(@NonNull BillingResult billingResult, @NonNull List productDetailsList) {
for(ProductDetails productDetails:productDetailsList) {
List pricingPhases = productDetails.getSubscriptionOfferDetails().get(0).getPricingPhases().getPricingPhaseList();
productId = productDetails.getProductId();
String formattedPrice = pricingPhases.get(0).getFormattedPrice();
String billingPeriod = pricingPhases.get(0).getBillingPeriod();
int recurrenceMode = pricingPhases.get(0).getRecurrenceMode();
String number, duration, bp;
bp = billingPeriod;
number = billingPeriod.substring(1, 2);
duration = billingPeriod.substring(2, 3);
if (recurrenceMode == 2) {
if (duration.equals("M")) {
offerDuration = "For " + number + " Month(s)";
} else if (duration.equals("Y")) {
offerDuration = "For " + number + " Year(s)";
} else if (duration.equals("W")) {
offerDuration = "For " + number + " Week(s)";
} else if (duration.equals("D")) {
offerDuration = "For " + number + " Days";
}
} else {
if (bp.equals("P1M")) {
offerDuration = " Monthly";
} else if (bp.equals("P6M")) {
offerDuration = " every 6 Months";
} else if (bp.equals("P1Y")) {
offerDuration = " Yearly";
} else if (bp.equals("P1W")) {
offerDuration = " Weekly";
}
}
phasesPlan = formattedPrice + " " + offerDuration;
for (int i = 0; i 0) {
String offrePeriod = pricingPhases.get(i).getBillingPeriod();
String price = pricingPhases.get(i).getFormattedPrice();
if (offrePeriod.equals("P1M")) {
offerDuration = " Monthly";
} else if (offrePeriod.equals("P6M")) {
offerDuration = " every 6 Months";
} else if (offrePeriod.equals("P1Y")) {
offerDuration = " Yearly";
} else if (offrePeriod.equals("P1W")) {
offerDuration = " Weekly";
} else {
offerDuration = "";
}
phasesPlan += "\n" + price + offerDuration;
}
}
// I moved this if part to different places, but it returns nothing or only the first plan details
if (productId.equals(productIdPlanA)) {
phasesPlanA = phasesPlan;
} else if (productId.equals(productIdPlanB)){
phasesPlanB = phasesPlan;
} else if (productId.equals(productIdPlanC)){
phasesPlanC = phasesPlan;
}
}
}
});
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Showing in Layout
tv_priceplana.setText(phasesPlanA);
tv_priceplanb.setText(phasesPlanB);
tv_priceplanc.setText(phasesPlanC);
}
});
}
}
@Override
public void onBillingServiceDisconnected() {
}
});
}
Подробнее здесь: https://stackoverflow.com/questions/793 ... -the-first
BillingClient.queryProductDetailsAsync возвращает сведения только о первой подписке, а не обо всех ⇐ JAVA
Программисты JAVA общаются здесь
1735121515
Anonymous
У меня есть 3 подписки: plana, planb, planc.
Каждая из них имеет 7-дневную бесплатную пробную версию и базовый план (начинающийся после пробного периода). p>
Мое приложение должно отображать цены на все три плана в соответствующем текстовом представлении (tv_priceplana, tv_priceplanb, tv_priceplanc), но отображает только первый из них (см. ниже). scrrenshots)
Что я получу в лучшем случае:
(что я получу)
Что я хочу:
(то, что я хочу)
Ниже приведена часть кода, показывающая детали планов.
Я не хочу Не понимаю, почему это работает только для деталей первого плана подписки (см. скриншот выше), а не для hte другие.
Я пытался переместить часть if (см. комментарий в коде) в разные места, но в лучшем случае это дает мне этапы первого плана (бесплатная пробная версия и базовый план), но а не другие. Что не так? Какой правильный код для этого?
Обратите внимание, что я также пытался очистить кеш и данные, и учтите, что я хочу сохранить свои textViews (а не переработчик) только для своих трех планы. А для информации я использую биллинговую версию 7.1.1
Заранее спасибо за помощь.
private void getSubsDetails(){
billingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(@NonNull BillingResult billingResult) {
if(billingResult.getResponseCode()== BillingClient.BillingResponseCode.OK){
ImmutableList productList = ImmutableList.of(
// Plan A //
QueryProductDetailsParams.Product.newBuilder()
.setProductId(productIdPlanA)
.setProductType(BillingClient.ProductType.SUBS)
.build(),
// Plan B //
QueryProductDetailsParams.Product.newBuilder()
.setProductId(productIdPlanB)
.setProductType(BillingClient.ProductType.SUBS)
.build(),
// Plan C //
QueryProductDetailsParams.Product.newBuilder()
.setProductId(productIdPlanC)
.setProductType(BillingClient.ProductType.SUBS)
.build()
);
QueryProductDetailsParams queryProductDetailsParams = QueryProductDetailsParams.newBuilder()
.setProductList(productList)
.build();
billingClient.queryProductDetailsAsync(queryProductDetailsParams, new ProductDetailsResponseListener() {
@Override
public void onProductDetailsResponse(@NonNull BillingResult billingResult, @NonNull List productDetailsList) {
for(ProductDetails productDetails:productDetailsList) {
List pricingPhases = productDetails.getSubscriptionOfferDetails().get(0).getPricingPhases().getPricingPhaseList();
productId = productDetails.getProductId();
String formattedPrice = pricingPhases.get(0).getFormattedPrice();
String billingPeriod = pricingPhases.get(0).getBillingPeriod();
int recurrenceMode = pricingPhases.get(0).getRecurrenceMode();
String number, duration, bp;
bp = billingPeriod;
number = billingPeriod.substring(1, 2);
duration = billingPeriod.substring(2, 3);
if (recurrenceMode == 2) {
if (duration.equals("M")) {
offerDuration = "For " + number + " Month(s)";
} else if (duration.equals("Y")) {
offerDuration = "For " + number + " Year(s)";
} else if (duration.equals("W")) {
offerDuration = "For " + number + " Week(s)";
} else if (duration.equals("D")) {
offerDuration = "For " + number + " Days";
}
} else {
if (bp.equals("P1M")) {
offerDuration = " Monthly";
} else if (bp.equals("P6M")) {
offerDuration = " every 6 Months";
} else if (bp.equals("P1Y")) {
offerDuration = " Yearly";
} else if (bp.equals("P1W")) {
offerDuration = " Weekly";
}
}
phasesPlan = formattedPrice + " " + offerDuration;
for (int i = 0; i 0) {
String offrePeriod = pricingPhases.get(i).getBillingPeriod();
String price = pricingPhases.get(i).getFormattedPrice();
if (offrePeriod.equals("P1M")) {
offerDuration = " Monthly";
} else if (offrePeriod.equals("P6M")) {
offerDuration = " every 6 Months";
} else if (offrePeriod.equals("P1Y")) {
offerDuration = " Yearly";
} else if (offrePeriod.equals("P1W")) {
offerDuration = " Weekly";
} else {
offerDuration = "";
}
phasesPlan += "\n" + price + offerDuration;
}
}
// I moved this if part to different places, but it returns nothing or only the first plan details
if (productId.equals(productIdPlanA)) {
phasesPlanA = phasesPlan;
} else if (productId.equals(productIdPlanB)){
phasesPlanB = phasesPlan;
} else if (productId.equals(productIdPlanC)){
phasesPlanC = phasesPlan;
}
}
}
});
runOnUiThread(new Runnable() {
@Override
public void run() {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
// Showing in Layout
tv_priceplana.setText(phasesPlanA);
tv_priceplanb.setText(phasesPlanB);
tv_priceplanc.setText(phasesPlanC);
}
});
}
}
@Override
public void onBillingServiceDisconnected() {
}
});
}
Подробнее здесь: [url]https://stackoverflow.com/questions/79307338/billingclient-queryproductdetailsasync-returning-only-the-details-for-the-first[/url]
Ответить
1 сообщение
• Страница 1 из 1
Перейти
- Кемерово-IT
- ↳ Javascript
- ↳ C#
- ↳ JAVA
- ↳ Elasticsearch aggregation
- ↳ Python
- ↳ Php
- ↳ Android
- ↳ Html
- ↳ Jquery
- ↳ C++
- ↳ IOS
- ↳ CSS
- ↳ Excel
- ↳ Linux
- ↳ Apache
- ↳ MySql
- Детский мир
- Для души
- ↳ Музыкальные инструменты даром
- ↳ Печатная продукция даром
- Внешняя красота и здоровье
- ↳ Одежда и обувь для взрослых даром
- ↳ Товары для здоровья
- ↳ Физкультура и спорт
- Техника - даром!
- ↳ Автомобилистам
- ↳ Компьютерная техника
- ↳ Плиты: газовые и электрические
- ↳ Холодильники
- ↳ Стиральные машины
- ↳ Телевизоры
- ↳ Телефоны, смартфоны, плашеты
- ↳ Швейные машинки
- ↳ Прочая электроника и техника
- ↳ Фототехника
- Ремонт и интерьер
- ↳ Стройматериалы, инструмент
- ↳ Мебель и предметы интерьера даром
- ↳ Cантехника
- Другие темы
- ↳ Разное даром
- ↳ Давай меняться!
- ↳ Отдам\возьму за копеечку
- ↳ Работа и подработка в Кемерове
- ↳ Давай с тобой поговорим...
Мобильная версия