Using the Google Play Billing v3 library, I want to dynamically list all the products that I have added to the Play Console without having to manually add the product IDs to my code. The following code snippet from the official documentation only shows how to add the product ID manually which is kinda hard-coded.
List<String> skuList = new ArrayList<> ();
skuList.add("premium_upgrade");
skuList.add("gas");
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(SkuType.INAPP);
billingClient.querySkuDetailsAsync(params.build(),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(BillingResult billingResult,
List<SkuDetails> skuDetailsList) {
// Process the result.
}
});
I will definitely be adding more products time and again and it would be quite inconvenient to manually have to add the product ID to my code and then have to roll out a new version of my app every time this happens. Also, if I have thousands of products, this would be a nightmare. What would be a way to solve this problem?