com.android.billingclient.api.SkuDetailsResponseListener Java Examples
The following examples show how to use
com.android.billingclient.api.SkuDetailsResponseListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BillingManager.java From PhoneProfilesPlus with Apache License 2.0 | 6 votes |
public void querySkuDetailsAsync(@BillingClient.SkuType final String itemType, final List<String> skuList, final SkuDetailsResponseListener listener) { // Specify a runnable to start when connection to Billing client is established Runnable executeOnConnectedService = new Runnable() { @Override public void run() { SkuDetailsParams skuDetailsParams = SkuDetailsParams.newBuilder() .setSkusList(skuList).setType(itemType).build(); mBillingClient.querySkuDetailsAsync(skuDetailsParams, new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(@NonNull BillingResult billingResult, List<SkuDetails> skuDetailsList) { listener.onSkuDetailsResponse(billingResult, skuDetailsList); } }); } }; // If Billing client was disconnected, we retry 1 time and if success, execute the query startServiceConnectionIfNeeded(executeOnConnectedService); }
Example #2
Source File: ActivityBilling.java From FairEmail with GNU General Public License v3.0 | 6 votes |
private void querySkus(List<String> query) { Log.i("IAB query SKUs"); SkuDetailsParams.Builder builder = SkuDetailsParams.newBuilder(); builder.setSkusList(query); builder.setType(BillingClient.SkuType.INAPP); billingClient.querySkuDetailsAsync(builder.build(), new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(BillingResult result, List<SkuDetails> skuDetailsList) { if (result.getResponseCode() == BillingClient.BillingResponseCode.OK) { for (SkuDetails skuDetail : skuDetailsList) { Log.i("IAB SKU detail=" + skuDetail); skuDetails.put(skuDetail.getSku(), skuDetail); for (IBillingListener listener : listeners) listener.onSkuDetails(skuDetail.getSku(), skuDetail.getPrice()); } } else reportError(result, "IAB query SKUs"); } }); }
Example #3
Source File: GooglePlayBillingVendorTest.java From Cashier with Apache License 2.0 | 6 votes |
@Test public void get_product_details_failure() { GooglePlayBillingVendor vendor = successfullyInitializedVendor(); ProductDetailsListener listener = mock(ProductDetailsListener.class); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { List<String> skus = invocation.getArgument(1); SkuDetailsResponseListener responseListener = invocation.getArgument(2); assertEquals(1, skus.size()); responseListener.onSkuDetailsResponse(BillingClient.BillingResponse.SERVICE_UNAVAILABLE, null); return null; } }).when(api).getSkuDetails(eq(BillingClient.SkuType.INAPP), ArgumentMatchers.<String>anyList(), any(SkuDetailsResponseListener.class)); vendor.getProductDetails(context, TestData.productInappA.sku(), false, listener); ArgumentCaptor<Vendor.Error> argumentError = ArgumentCaptor.forClass(Vendor.Error.class); verify(listener).failure(argumentError.capture()); assertEquals(VendorConstants.PRODUCT_DETAILS_UNAVAILABLE, argumentError.getValue().code); }
Example #4
Source File: TestHelper.java From Cashier with Apache License 2.0 | 6 votes |
static void mockApiUnavailable(AbstractGooglePlayBillingApi api) { doAnswer( new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { throw new IllegalStateException("Billing client is not available"); } } ).when(api).getSkuDetails( anyString(), Mockito.<String>anyList(), any(SkuDetailsResponseListener.class)); when(api.available()).thenReturn(false); when(api.getPurchases(anyString())).thenThrow(new IllegalStateException("Billing client is not available")); }
Example #5
Source File: BillingManager.java From play-billing-codelab with Apache License 2.0 | 6 votes |
public void querySkuDetailsAsync(@BillingClient.SkuType final String itemType, final List<String> skuList, final SkuDetailsResponseListener listener) { // Specify a runnable to start when connection to Billing client is established Runnable executeOnConnectedService = new Runnable() { @Override public void run() { SkuDetailsParams skuDetailsParams = SkuDetailsParams.newBuilder() .setSkusList(skuList).setType(itemType).build(); mBillingClient.querySkuDetailsAsync(skuDetailsParams, new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { listener.onSkuDetailsResponse(responseCode, skuDetailsList); } }); } }; // If Billing client was disconnected, we retry 1 time and if success, execute the query startServiceConnectionIfNeeded(executeOnConnectedService); }
Example #6
Source File: TestHelper.java From Cashier with Apache License 2.0 | 6 votes |
static void mockSkuDetails(AbstractGooglePlayBillingApi api, String type, final Map<String, SkuDetails> skuDetailsMap) { doAnswer( new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { List<String> skus = invocation.getArgument(1); SkuDetailsResponseListener listener = invocation.getArgument(2); List<SkuDetails> result = new ArrayList<>(); for (String sku : skus) { result.add(skuDetailsMap.get(sku)); } listener.onSkuDetailsResponse(BillingClient.BillingResponse.OK, result); return null; } } ).when(api).getSkuDetails( eq(type), Mockito.<String>anyList(), any(SkuDetailsResponseListener.class)); }
Example #7
Source File: AcquireFragment.java From play-billing-codelab with Apache License 2.0 | 6 votes |
/** * Executes query for SKU details at the background thread */ private void handleManagerAndUiReady() { // Start querying for SKUs List<String> inAppSkus = mBillingProvider.getBillingManager().getSkus(SkuType.INAPP); mBillingProvider.getBillingManager().querySkuDetailsAsync(SkuType.INAPP, inAppSkus, new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { if (responseCode == BillingResponse.OK && skuDetailsList != null) { for (SkuDetails details : skuDetailsList) { Log.w(TAG, "Got a SKU: " + details); } } } }); // Show the UI displayAnErrorIfNeeded(); }
Example #8
Source File: InventoryQueryTest.java From Cashier with Apache License 2.0 | 6 votes |
@Test public void returns_inventory() { InventoryListener listener = mock(InventoryListener.class); InventoryQuery.execute( TestHelper.mockThreading(), api, listener, TestData.allInAppSkus, TestData.allSubSkus ); ArgumentCaptor<Inventory> argument = ArgumentCaptor.forClass(Inventory.class); // Check if API gets called correctly verify(api).getPurchases(BillingClient.SkuType.SUBS); verify(api).getPurchases(BillingClient.SkuType.INAPP); verify(api).getSkuDetails(eq(BillingClient.SkuType.SUBS), eq(TestData.allSubSkus), any(SkuDetailsResponseListener.class)); verify(api).getSkuDetails(eq(BillingClient.SkuType.INAPP), eq(TestData.allInAppSkus), any(SkuDetailsResponseListener.class)); // Check if result is delivered verify(listener).success(argument.capture()); assertEquals(TestData.allProducts.size(), argument.getValue().products().size()); assertEquals(1, argument.getValue().purchases().size()); for (Product product : argument.getValue().products()) { assertTrue(TestData.allProducts.contains(product)); } }
Example #9
Source File: GooglePlayBillingVendor.java From Cashier with Apache License 2.0 | 6 votes |
@Override public void getProductDetails(@NonNull Context context, @NonNull final String sku, final boolean isSubscription, @NonNull final ProductDetailsListener listener) { throwIfUninitialized(); api.getSkuDetails( isSubscription ? SkuType.SUBS : SkuType.INAPP, Collections.singletonList(sku), new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { if (responseCode == BillingResponse.OK && skuDetailsList.size() == 1) { logSafely("Successfully got sku details for " + sku + "!"); listener.success( GooglePlayBillingProduct.create(skuDetailsList.get(0), isSubscription ? SkuType.SUBS : SkuType.INAPP) ); } else { logSafely("Error getting sku details for " + sku + " with code "+responseCode); listener.failure(getDetailsError(responseCode)); } } } ); }
Example #10
Source File: PictureInPictureUpgradeActivity.java From dtube-mobile-unofficial with Apache License 2.0 | 5 votes |
public void loadSKUs(){ List<String> skuList = new ArrayList<>(); skuList.add("upgrade"); SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder(); params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP); billingClient.querySkuDetailsAsync(params.build(), new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList) { if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && !skuDetailsList.isEmpty()) { for (SkuDetails skuDetails : skuDetailsList) { if (skuDetails.getSku().equals("upgrade")){ findViewById(R.id.upgrade_button).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { BillingFlowParams billingFlowParams = BillingFlowParams .newBuilder() .setSkuDetails(skuDetails) .build(); billingClient.launchBillingFlow(PictureInPictureUpgradeActivity.this, billingFlowParams); } }); } } } } }); }
Example #11
Source File: GooglePlayBillingVendorTest.java From Cashier with Apache License 2.0 | 5 votes |
@Test public void get_product_details() { GooglePlayBillingVendor vendor = successfullyInitializedVendor(); ProductDetailsListener listener = mock(ProductDetailsListener.class); doAnswer(new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { List<String> skus = invocation.getArgument(1); SkuDetailsResponseListener responseListener = invocation.getArgument(2); assertEquals(1, skus.size()); responseListener.onSkuDetailsResponse(BillingClient.BillingResponse.OK, Collections.singletonList( TestData.getSkuDetail(skus.get(0)) )); return null; } }).when(api).getSkuDetails(eq(BillingClient.SkuType.INAPP), ArgumentMatchers.<String>anyList(), any(SkuDetailsResponseListener.class)); vendor.getProductDetails(context, TestData.productInappA.sku(), false, listener); ArgumentCaptor<List<String>> argumentSkus = ArgumentCaptor.forClass(List.class); verify(api).getSkuDetails(eq(BillingClient.SkuType.INAPP), argumentSkus.capture(), any(SkuDetailsResponseListener.class)); assertEquals(1, argumentSkus.getValue().size()); assertEquals(TestData.productInappA.sku(), argumentSkus.getValue().get(0)); ArgumentCaptor<Product> argumentProduct = ArgumentCaptor.forClass(Product.class); verify(listener).success(argumentProduct.capture()); assertEquals(TestData.productInappA, argumentProduct.getValue()); }
Example #12
Source File: TestHelper.java From Cashier with Apache License 2.0 | 5 votes |
static void mockSkuDetailsError(AbstractGooglePlayBillingApi api, String type) { doAnswer( new Answer() { @Override public Object answer(InvocationOnMock invocation) throws Throwable { SkuDetailsResponseListener listener = invocation.getArgument(2); listener.onSkuDetailsResponse(BillingClient.BillingResponse.SERVICE_UNAVAILABLE, null); return null; } } ).when(api).getSkuDetails( eq(type), Mockito.<String>anyList(), any(SkuDetailsResponseListener.class)); }
Example #13
Source File: InventoryQueryTest.java From Cashier with Apache License 2.0 | 5 votes |
@Test public void returns_inventory_when_subs_feature_not_available() { when(api.isBillingSupported(BillingClient.SkuType.SUBS)).thenReturn(BillingClient.BillingResponse.FEATURE_NOT_SUPPORTED); InventoryListener listener = mock(InventoryListener.class); InventoryQuery.execute( TestHelper.mockThreading(), api, listener, TestData.allInAppSkus, TestData.allSubSkus ); ArgumentCaptor<Inventory> argument = ArgumentCaptor.forClass(Inventory.class); // Check if API gets called correctly verify(api).getPurchases(BillingClient.SkuType.INAPP); verify(api, never()).getPurchases(BillingClient.SkuType.SUBS); verify(api).getSkuDetails(eq(BillingClient.SkuType.INAPP), eq(TestData.allInAppSkus), any(SkuDetailsResponseListener.class)); verify(api, Mockito.never()).getSkuDetails(eq(BillingClient.SkuType.SUBS), eq(TestData.allSubSkus), any(SkuDetailsResponseListener.class)); // Check if result is delivered verify(listener).success(argument.capture()); assertEquals(TestData.allInAppProducts.size(), argument.getValue().products().size()); assertEquals(1, argument.getValue().purchases().size()); for (Product product : argument.getValue().products()) { assertTrue(TestData.allProducts.contains(product)); } }
Example #14
Source File: GooglePlayBillingApi.java From Cashier with Apache License 2.0 | 5 votes |
@Override public void launchBillingFlow(@NonNull final Activity activity, @NonNull String sku, @SkuType String itemType) { throwIfUnavailable(); logSafely("Launching billing flow for " + sku + " with type " + itemType); getSkuDetails( itemType, Collections.singletonList(sku), new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { try { if (responseCode == BillingResponse.OK && skuDetailsList.size() > 0) { BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder() .setSkuDetails(skuDetailsList.get(0)) .build(); // This will call the {@link PurchasesUpdatedListener} specified in {@link #initialize} billing.launchBillingFlow(activity, billingFlowParams); } else { vendor.onPurchasesUpdated(BillingResponse.ERROR, null); } } catch (Exception e) { vendor.onPurchasesUpdated(BillingResponse.ERROR, null); } } } ); }
Example #15
Source File: GooglePlayBillingApi.java From Cashier with Apache License 2.0 | 5 votes |
@Override public void getSkuDetails(@SkuType String itemType, @NonNull List<String> skus, @NonNull SkuDetailsResponseListener listener) { throwIfUnavailable(); logSafely("Query for SKU details with type: " + itemType + " SKUs: " + TextUtils.join(",", skus)); SkuDetailsParams query = SkuDetailsParams.newBuilder() .setSkusList(skus) .setType(itemType) .build(); billing.querySkuDetailsAsync(query, listener); }
Example #16
Source File: BillingManager.java From SchoolQuest with GNU General Public License v3.0 | 5 votes |
public void querySkuDetailsAsync(@BillingClient.SkuType final String itemType, final List<String> skuList, final SkuDetailsResponseListener listener) { SkuDetailsParams skuDetailsParams = SkuDetailsParams.newBuilder().setSkusList(skuList). setType(itemType).build(); mBillingClient.querySkuDetailsAsync(skuDetailsParams, new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { listener.onSkuDetailsResponse(responseCode, skuDetailsList); } }); }
Example #17
Source File: BillingManager.java From play-billing-codelab with Apache License 2.0 | 5 votes |
public void querySkuDetailsAsync(@BillingClient.SkuType final String itemType, final List<String> skuList, final SkuDetailsResponseListener listener) { SkuDetailsParams skuDetailsParams = SkuDetailsParams.newBuilder() .setSkusList(skuList).setType(itemType).build(); mBillingClient.querySkuDetailsAsync(skuDetailsParams, new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { listener.onSkuDetailsResponse(responseCode, skuDetailsList); } }); }
Example #18
Source File: AcquireFragment.java From play-billing-codelab with Apache License 2.0 | 5 votes |
/** * Executes query for SKU details at the background thread */ private void handleManagerAndUiReady() { final List<SkuRowData> inList = new ArrayList<>(); SkuDetailsResponseListener responseListener = new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { if (responseCode == BillingResponse.OK && skuDetailsList != null) { // Repacking the result for an adapter for (SkuDetails details : skuDetailsList) { Log.i(TAG, "Found sku: " + details); inList.add(new SkuRowData(details.getSku(), details.getTitle(), details.getPrice(), details.getDescription(), details.getType())); } if (inList.size() == 0) { displayAnErrorIfNeeded(); } else { mAdapter.updateData(inList); setWaitScreen(false); } } } }; // Start querying for in-app SKUs List<String> skus = mBillingProvider.getBillingManager().getSkus(SkuType.INAPP); mBillingProvider.getBillingManager().querySkuDetailsAsync(SkuType.INAPP, skus, responseListener); // Start querying for subscriptions SKUs skus = mBillingProvider.getBillingManager().getSkus(SkuType.SUBS); mBillingProvider.getBillingManager().querySkuDetailsAsync(SkuType.SUBS, skus, responseListener); }
Example #19
Source File: BillingManager.java From play-billing-codelab with Apache License 2.0 | 5 votes |
public void querySkuDetailsAsync(@BillingClient.SkuType final String itemType, final List<String> skuList, final SkuDetailsResponseListener listener) { SkuDetailsParams skuDetailsParams = SkuDetailsParams.newBuilder().setSkusList(skuList) .setType(itemType).build(); mBillingClient.querySkuDetailsAsync(skuDetailsParams, new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { listener.onSkuDetailsResponse(responseCode, skuDetailsList); } }); }
Example #20
Source File: BillingManager.java From play-billing-codelab with Apache License 2.0 | 5 votes |
public void querySkuDetailsAsync(@BillingClient.SkuType final String itemType, final List<String> skuList, final SkuDetailsResponseListener listener) { SkuDetailsParams skuDetailsParams = SkuDetailsParams.newBuilder() .setSkusList(skuList).setType(itemType).build(); mBillingClient.querySkuDetailsAsync(skuDetailsParams, new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { listener.onSkuDetailsResponse(responseCode, skuDetailsList); } }); }
Example #21
Source File: AcquireFragment.java From play-billing-codelab with Apache License 2.0 | 5 votes |
/** * Executes query for SKU details at the background thread */ private void handleManagerAndUiReady() { final List<SkuRowData> inList = new ArrayList<>(); SkuDetailsResponseListener responseListener = new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { if (responseCode == BillingResponse.OK && skuDetailsList != null) { // Repacking the result for an adapter for (SkuDetails details : skuDetailsList) { Log.i(TAG, "Found sku: " + details); inList.add(new SkuRowData(details.getSku(), details.getTitle(), details.getPrice(), details.getDescription(), details.getType())); } if (inList.size() == 0) { displayAnErrorIfNeeded(); } else { mAdapter.updateData(inList); setWaitScreen(false); } } } }; // Start querying for in-app SKUs List<String> skus = mBillingProvider.getBillingManager().getSkus(SkuType.INAPP); mBillingProvider.getBillingManager().querySkuDetailsAsync(SkuType.INAPP, skus, responseListener); // Start querying for subscriptions SKUs skus = mBillingProvider.getBillingManager().getSkus(SkuType.SUBS); mBillingProvider.getBillingManager().querySkuDetailsAsync(SkuType.SUBS, skus, responseListener); }
Example #22
Source File: AcquireFragment.java From play-billing-codelab with Apache License 2.0 | 5 votes |
/** * Executes query for SKU details at the background thread */ private void handleManagerAndUiReady() { final List<SkuRowData> inList = new ArrayList<>(); SkuDetailsResponseListener responseListener = new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { // If we successfully got SKUs, add a header in front of it if (responseCode == BillingResponse.OK && skuDetailsList != null) { // Repacking the result for an adapter for (SkuDetails details : skuDetailsList) { Log.i(TAG, "Found sku: " + details); inList.add(new SkuRowData(details.getSku(), details.getTitle(), details.getPrice(), details.getDescription(), details.getType())); } if (inList.size() == 0) { displayAnErrorIfNeeded(); } else { mAdapter.updateData(inList); setWaitScreen(false); } } } }; // Start querying for in-app SKUs List<String> skus = mBillingProvider.getBillingManager().getSkus(SkuType.INAPP); mBillingProvider.getBillingManager().querySkuDetailsAsync(SkuType.INAPP, skus, responseListener); // Start querying for subscriptions SKUs skus = mBillingProvider.getBillingManager().getSkus(SkuType.SUBS); mBillingProvider.getBillingManager().querySkuDetailsAsync(SkuType.SUBS, skus, responseListener); }
Example #23
Source File: BillingPlugin.java From flutter_billing with Apache License 2.0 | 5 votes |
private void fetchSubscriptions(final List<String> identifiers, final Result result) { executeServiceRequest(new Request() { @Override public void execute() { billingClient.querySkuDetailsAsync( SkuDetailsParams.newBuilder() .setSkusList(identifiers) .setType(SkuType.SUBS) .build(), new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { if (responseCode == BillingResponse.OK) { List<Map<String, Object>> products = getProductsFromSkuDetails(skuDetailsList); result.success(products); } else { result.error("ERROR", "Failed to fetch Subscriptions!", null); } } }); } @Override public void failed() { result.error("UNAVAILABLE", "Billing service is unavailable!", null); } }); }
Example #24
Source File: BillingPlugin.java From flutter_billing with Apache License 2.0 | 5 votes |
private void fetchProducts(final List<String> identifiers, final Result result) { executeServiceRequest(new Request() { @Override public void execute() { billingClient.querySkuDetailsAsync( SkuDetailsParams.newBuilder() .setSkusList(identifiers) .setType(SkuType.INAPP) .build(), new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) { if (responseCode == BillingResponse.OK) { List<Map<String, Object>> products = getProductsFromSkuDetails(skuDetailsList); result.success(products); } else { result.error("ERROR", "Failed to fetch products!", null); } } }); } @Override public void failed() { result.error("UNAVAILABLE", "Billing service is unavailable!", null); } }); }
Example #25
Source File: AccelerateDevelop.java From InviZible with GNU General Public License v3.0 | 5 votes |
private void querySkuDetails() { if (!billingServiceConnected) { mBillingClient.startConnection(this); return; } SkuDetailsParams.Builder skuDetailsParamsBuilder = SkuDetailsParams.newBuilder(); List<String> skuList = new ArrayList<>(); skuList.add(mSkuId); skuDetailsParamsBuilder.setSkusList(skuList).setType(BillingClient.SkuType.INAPP); mBillingClient.querySkuDetailsAsync(skuDetailsParamsBuilder.build(), new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(BillingResult billingResult, List<SkuDetails> skuDetailsList) { if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) { if (!skuDetailsList.isEmpty()) { for (SkuDetails skuDetails : skuDetailsList) { mSkuDetailsMap.put(skuDetails.getSku(), skuDetails); } } else { Log.w(LOG_TAG, "Query SKU details is OK, but SKU list is empty " + billingResult.getDebugMessage()); } } else { Log.w(LOG_TAG, "Query SKU details warning " + billingResult.getResponseCode() + " " + billingResult.getDebugMessage()); } } }); }
Example #26
Source File: AbstractGooglePlayBillingApi.java From Cashier with Apache License 2.0 | 4 votes |
public abstract void getSkuDetails(@SkuType String itemType, @NonNull List<String> skus, @NonNull SkuDetailsResponseListener listener);
Example #27
Source File: DonationFragment.java From PhoneProfilesPlus with Apache License 2.0 | 4 votes |
public void updateGUIAfterBillingConnected() { // Start querying for SKUs //PPApplication.logE(TAG, "handleManagerAndUiReady"); final List<String> inAppSkus = mBillingProvider.getBillingManager() .getSkus(/*!mDebug, */BillingClient.SkuType.INAPP); mBillingProvider.getBillingManager().querySkuDetailsAsync(BillingClient.SkuType.INAPP, inAppSkus, new SkuDetailsResponseListener() { @Override public void onSkuDetailsResponse(@NonNull BillingResult billingResult, List<SkuDetails> skuDetailsList) { int responseCode = billingResult.getResponseCode(); //PPApplication.logE(TAG, "onSkuDetailsResponse responseCode="+responseCode); String[] prices = new String[]{"1 €", "2 €", "3 €", "5 €", "8 €", "13 €", "20 €"}; //if (skuDetailsList != null) // PPApplication.logE(TAG, "onSkuDetailsResponse skuDetailsList="+skuDetailsList.size()); if (responseCode == BillingClient.BillingResponseCode.OK && skuDetailsList != null) { if (skuDetailsList.size() > 0) { SKU_DETAILS = new ArrayList<>(); for (int i = 0; i < inAppSkus.size(); i++) { for (int j = 0; j < skuDetailsList.size(); j++) { if (skuDetailsList.get(j).getSku().equals(inAppSkus.get(i))) { //PPApplication.logE(TAG, "Found sku: " + skuDetailsList.get(j)); SKU_DETAILS.add(skuDetailsList.get(j)); prices[i] = skuDetailsList.get(j).getPrice(); break; } } } // update the UI displayAnErrorIfNeeded(BillingClient.BillingResponseCode.OK); if (getActivity() != null) { mGoogleGridView.setAdapter(new DonationGooglePlayAdapter(DonationFragment.this, prices)); mGoogleGridView.setOnItemClickListener(new AdapterView.OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { donateGoogleOnClick(position); } }); mGoogleGridView.setEnabled(true); // GlobalGUIRoutines.HighlightedSpinnerAdapter spinnerAdapter = new GlobalGUIRoutines.HighlightedSpinnerAdapter( // getActivity(), // R.layout.highlighted_spinner, // prices); // mGoogleSpinner.setSupportBackgroundTintList(ContextCompat.getColorStateList(getActivity().getBaseContext(), R.color.accent)); // spinnerAdapter.setDropDownViewResource(R.layout.highlighted_spinner_dropdown); // mGoogleSpinner.setAdapter(spinnerAdapter); // // mGoogleSpinner.setSelection(0); // mGoogleSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { // // public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // ((GlobalGUIRoutines.HighlightedSpinnerAdapter)mGoogleSpinner.getAdapter()).setSelection(position); // } // // public void onNothingSelected(AdapterView<?> parent) { // } // }); // // btGoogle.setEnabled(true); } } else { displayAnErrorIfNeeded(BillingClient.BillingResponseCode.FEATURE_NOT_SUPPORTED); } } } }); }