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?
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.
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