When attempting to launch billing for an in-app item, I am getting the following error.
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String android.content.Intent.getStringExtra(java.lang.String)' on a null object reference
The code is simple. The user selects an item. I then pass that item into querySkuDetailsAsync. I get and see the result. For API reasons, I then call...
SkuDetails skuDetails = new SkuDetails(skuDetails.getOriginalJSON());
BillingFlowParams flowParams = BillingFlowParams.newBuilder().setSkuDetails(skuDetails).build();
BillingResult billingResult = client.launchBillingFlow(activity, flowParams);
And then, most of the time, I get the NPE. Things were working fine. I don't know what change caused this issue.
Note that I did try passing the skuDetails directly, in case JSON was the issue. It didn't work.
The billing library isn't open source, so I am at a loss as to how to solve this issue.
I found a solution. If I call activity.setIntent(new Intent()) before calling "launchBillingFlow", the error goes away. Seems like a bug in the now closed sourced billing library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With