Android Question Android in-app billing purchase crashing the app

asales

Expert
Licensed User
Longtime User
In some devices (not all) I get this error when the user clicks to remove ads in my app:

B4X:
~e:java.lang.NullPointerException: Attempt to invoke virtual method 'void anywheresoftware.b4a.objects.IbHelper.launchPurchaseFlow(android.app.Activity, java.lang.String, java.lang.String, int, anywheresoftware.b4a.objects.IbHelper$OnIabPurchaseFinishedListener, java.lang.String, anywheresoftware.b4a.BA)' on a null object reference
~e: at anywheresoftware.b4a.inappbilling3.BillingManager3.RequestPayment(BillingManager3.java:91)

my code is:
B4X:
billman3.RequestPayment("noad", "inapp", DeveloperPayload)

Sub billman3_BillingSupported (Supported As Boolean, Message As String)
    Try
        If Supported Then billman3.GetOwnedProducts       
    Catch
        ToastMessageShow(LastException.Message, False)
        Log(LastException)
    End Try
End Sub
 

asales

Expert
Licensed User
Longtime User
Have you waited for the BillingSupported event to be raised?
I think so. This is the other part of the code:
B4X:
Sub billman3_OwnedProducts (Success As Boolean, purchases As Map)
    If Success Then       
        If purchases.Size > 0 Then
            Try
                For Each p As Purchase In purchases.Values
                    If (p.ProductId = "noad") And (p.PurchaseState = p.STATE_PURCHASED) Then
                        RemoveAdvertisement(True)   
                    End If
                Next
            Catch
                Log(LastException)
            End Try
        Else
            RemoveAdvertisement(False)
        End If
    Else
        RemoveAdvertisement(False)
    End If   
End Sub

What is the value of Supported parameter?
In my device I don't get this error and the Supported shows "True" and Message shows "Setup successful. (response: 0:OK)"
 
Upvote 0
Top