android-inapp-billing-v3 icon indicating copy to clipboard operation
android-inapp-billing-v3 copied to clipboard

bp!!.getPurchaseListingDetails(productIDs) returns null in Kotlin version

Open PSNAppz opened this issue 4 years ago • 4 comments

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)
        }

PSNAppz avatar Aug 02 '19 11:08 PSNAppz

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

atadn avatar Aug 03 '19 16:08 atadn

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

PSNAppz avatar Aug 03 '19 21:08 PSNAppz

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();
    }

memishood avatar Jan 31 '20 19:01 memishood

Here is the solution:-

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

jmimohsin avatar Apr 19 '20 16:04 jmimohsin