android-inapp-billing-v3
android-inapp-billing-v3 copied to clipboard
bp!!.getPurchaseListingDetails(productIDs) returns null in Kotlin version
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)
}
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())
}