Skip to content

Instantly share code, notes, and snippets.

@ponnamkarthik
Last active February 11, 2019 04:20
Show Gist options
  • Save ponnamkarthik/81df8b126e5fc73d084e22574b73ae5b to your computer and use it in GitHub Desktop.
Save ponnamkarthik/81df8b126e5fc73d084e22574b73ae5b to your computer and use it in GitHub Desktop.
In-app billing Items available for purchase
List<String> skuList = new ArrayList<>();
skuList.add("product_1");
skuList.add("product_2");
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP);
mBillingClient.querySkuDetailsAsync(params.build(),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(int responseCode, List<SkuDetails> skuDetailsList) {
if (responseCode == BillingClient.BillingResponse.OK
&& skuDetailsList != null) {
for (SkuDetails skuDetails : skuDetailsList) {
String sku = skuDetails.getSku();
String price = skuDetails.getPrice();
if ("product_1".equals(sku)) {
Toast.makeText(MainActivity.this, "Product 1", Toast.LENGTH_SHORT).show();
} else if ("product_2".equals(sku)) {
Toast.makeText(MainActivity.this, "Product 2", Toast.LENGTH_SHORT).show();
}
}
}
}
});
@shadygoneinsane
Copy link

shadygoneinsane commented Aug 19, 2018

whats the purpose ofstartSubscribe()here ?

@ponnamkarthik
Copy link
Author

@shadygoneinsane that came by mistake

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment