Android-inapp-billing-v3: bp!!.getPurchaseListingDetails(productIDs) returns null in Kotlin version

Created on 2 Aug 2019  路  4Comments  路  Source: anjlab/android-inapp-billing-v3

This was working in the Java version of my app. Recently, I ported my app to Kotlin and it returns null.

 override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.activity_purchase)
        bp = BillingProcessor(this, resources.getString(R.string.devKey), this)
        bp!!.initialize()

        val Data: List<SkuDetails>
        val productIDs = ArrayList<String>()
        productIDs.add("product1")
        productIDs.add("product2")

        try {

            Data = bp!!.getPurchaseListingDetails(productIDs) // Here is the problem
            .
            .
            .
        }catch(e: Exception){
            Log.d("BillingError", e.message)
        }

Most helpful comment

Here is the solution:-

override fun onBillingInitialized() {
        val skuDetails= bp!!.getSubscriptionListingDetails("Product_id")
        println(skuDetails.toString())
    }

All 4 comments

I'm having similar problems. Did you find a solution?

The only solution is to revert the file back to java (for now).

you should get on the onPurchaseHistoryRestored ovverride func. as like:

@Override
    public void onPurchaseHistoryRestored() {
        List<SkuDetails> skuDetails = bp.getSubscriptionListingDetails(Constants.skuList);
        StoreActivity.this.skuDetails.addAll(skuDetails);
        adapter.notifyDataSetChanged();
    }

Here is the solution:-

override fun onBillingInitialized() {
        val skuDetails= bp!!.getSubscriptionListingDetails("Product_id")
        println(skuDetails.toString())
    }
Was this page helpful?
0 / 5 - 0 ratings