Android Question Problem in GooglePlayBilling with subscriptions when call LaunchBillingFlow

Mr.Coder

Member
Licensed User
Longtime User
Hi,

Problem in GooglePlayBilling with subscriptions when call LaunchBillingFlowthe Billing_PurchasesUpdated event called two times in log there is two of this "sending message to waiting queue (billing_purchasesupdated)" and when I click on the subscription button and after the subscription information window disappears this "running waiting messages (2)" appears in the log the event is called twice, causing a fatal error when the event is called for the second time.

B4X:
Logger connected to:  HUAWEI INE-LX1
--------- beginning of main
--------- beginning of system
*** Receiver (httputils2service) Receive (first time) ***
(Http client initialized with accept all option.)
Panel size is unknown. Layout may not be loaded correctly.
** Activity (main) Pause, UserClosed = false **
sending message to waiting queue (billing_purchasesupdated)
sending message to waiting queue (billing_purchasesupdated)
running waiting messages (2)
main$ResumeMessagerun (java line: 340)
java.lang.Exception: Sub billing_purchasesupdated was not found.
    at anywheresoftware.b4a.BA.raiseEvent2(BA.java:227)
    at anywheresoftware.b4a.BA$2.run(BA.java:395)
    at anywheresoftware.b4a.BA.setActivityPaused(BA.java:467)
    at com.moderndigitals.fakegps.main$ResumeMessage.run(main.java:340)
    at android.os.Handler.handleCallback(Handler.java:907)
    at android.os.Handler.dispatchMessage(Handler.java:105)
    at android.os.Looper.loop(Looper.java:216)
    at android.app.ActivityThread.main(ActivityThread.java:7625)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:524)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:987)
java.lang.Exception: Sub billing_purchasesupdated was not found.
** Activity (main) Resume **
** Activity (main) Pause, UserClosed = false **

The code I use :

B4X:
                 Dim Offers As List = SkuDetails.Get(0).As(JavaObject).RunMethod("getSubscriptionOfferDetails", Null)
                 Dim Offer As JavaObject = Offers.Get(0)
                 Dim OfferToken As String = Offer.RunMethod("getOfferToken", Null)

                 Dim lResult As BillingResult = LaunchBillingFlow2(Billing, SkuDetails.Get(0), OfferToken)

B4X:
Private Sub LaunchBillingFlow2 (Client As BillingClient, Sku As SkuDetails, OfferToken As String) As BillingResult

    Try
  
        Dim oContext As JavaObject
        Dim JustForError As BillingResult
        Dim ProductDetailsParamsBuilder As JavaObject
        Dim ProductDetails As List
        Dim BillingFlowParamsBuilder As JavaObject
      
        oContext.InitializeContext
      
        ProductDetailsParamsBuilder = ProductDetailsParamsBuilder.InitializeStatic("com.android.billingclient.api.BillingFlowParams.ProductDetailsParams").RunMethod("newBuilder", Null)
        ProductDetailsParamsBuilder.RunMethod("setProductDetails", Array(Sku))
        ProductDetailsParamsBuilder.RunMethod("setOfferToken", Array(OfferToken))
        ProductDetails = Array(ProductDetailsParamsBuilder.RunMethod("build", Null))
              
        BillingFlowParamsBuilder = BillingFlowParamsBuilder.InitializeStatic("com.android.billingclient.api.BillingFlowParams").RunMethod("newBuilder", Null)
        BillingFlowParamsBuilder.RunMethod("setProductDetailsParamsList", Array(ProductDetails))
      
        Return Client.As(JavaObject).GetFieldJO("client").RunMethod("launchBillingFlow", Array(oContext, BillingFlowParamsBuilder.RunMethod("build", Null)))

    Catch
      
        Log(LastException)
      
        Return JustForError
      
    End Try
  
End Sub

I have tried these versions v7.01 and v7.02 and v8.00 from the GooglePlayBilling library and the same problem and fatal error occurs in all of them, I don't know what the problem is, thank you.
 
Last edited:
Top