Android-inapp-billing-v3: getPurchaseListingDetails() returns null

Created on 17 Sep 2015  路  2Comments  路  Source: anjlab/android-inapp-billing-v3

I'm trying to get the price of my IAP to display it in the app.

So mBillingProcessor.getPurchaseListingDetails("my.product.id").priceText; gives me a nullpointer exception.

mBillingProcessor.purchase(MainActivity.this, "my.product.id"); works though. What am I doing wrong?

Most helpful comment

Weird, when called in an OnClickListener it works as intended:

findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SkuDetails sku = mBillingProcessor.getPurchaseListingDetails(iap1);
Log.d("purchase", sku.priceText);
}
});

EDIT: Seems like this doesnt work before onBillingInitialized() is called, that's why it crashed when called in onCreate

All 2 comments

Weird, when called in an OnClickListener it works as intended:

findViewById(R.id.button1).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
SkuDetails sku = mBillingProcessor.getPurchaseListingDetails(iap1);
Log.d("purchase", sku.priceText);
}
});

EDIT: Seems like this doesnt work before onBillingInitialized() is called, that's why it crashed when called in onCreate

I got this nullpointer exception too. The probleme was: you have to add some time before calling those methods: I added 200 ms after initialized the BP.

Was this page helpful?
0 / 5 - 0 ratings