Android Question Firebase Exception: Can't start async operation (refresh inventory) because ...

Filippo

Expert
Licensed User
Hi,

I have a Firebase Exception here, I can not find a bug in my code.

Can't start async operation (refresh inventory) because another async operation(refresh inventory) is in progress.
Which should be the second "async operation"?

Firebase Exception:
Fatal Exception: java.lang.IllegalStateException: Can't start async operation (refresh inventory) because another async operation(refresh inventory) is in progress.
at anywheresoftware.b4a.objects.IbHelper.flagStartAsync(IbHelper.java:816)
at anywheresoftware.b4a.objects.IbHelper.queryInventoryAsync(IbHelper.java:612)
at anywheresoftware.b4a.inappbilling3.BillingManager3.GetInventoryInformation(BillingManager3.java:105)
at fg.MasterOfRegolarity.main._vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv0(main.java:2978)
at fg.MasterOfRegolarity.main$ResumableSub_mnuInAppBilling_Click.resume(main.java:2675)
at fg.MasterOfRegolarity.main._mnuinappbilling_click(main.java:2536)
at fg.MasterOfRegolarity.main._clvmenu_itemclick(main.java:1761)
at java.lang.reflect.Method.invoke(Method.java)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.keywords.Common.CallSub4(Common.java:1068)
at anywheresoftware.b4a.keywords.Common.CallSubNew3(Common.java:1031)
at fg.MasterOfRegolarity.customlistview._panel_click(customlistview.java:488)
at java.lang.reflect.Method.invoke(Method.java)
at anywheresoftware.b4a.BA.raiseEvent2(BA.java:196)
at anywheresoftware.b4a.BA.raiseEvent(BA.java:176)
at anywheresoftware.b4a.objects.ViewWrapper$1.onClick(ViewWrapper.java:80)
at android.view.View.performClick(View.java:5646)
at android.view.View$PerformClick.run(View.java:22473)
at android.os.Handler.handleCallback(Handler.java:761)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:156)
at android.app.ActivityThread.main(ActivityThread.java:6523)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:942)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:832)
Device:
Gerät
Marke: HUAWEI
Modell: HUAWEI P9 lite
Ausrichtung: Hochformat
Freier RAM: 1.1 GB
Freier Festplattenspeicher: 690.31 MB

Betriebssystem
Version: 7.0
Ausrichtung: Hochformat
Rooting durchgeführt: Nein

Absturz
Datum: 27.02.2019, 19:31:00
App-Version: 2.14 (30)
My Code:
B4X:
Private Sub mnuInAppBilling_Click
   If Not(Starter.IsBillingSupported) Then
       ToastMessageShow(Starter.language.value("strInAppBillingError"),True)
       Return
   Else
       If Starter.IsLicensevalid Then
           Msgbox2Async(Starter.language.value("strLicenseIsValid"), "Info", Starter.language.Value("strJa"), Starter.language.Value("strCancel"),"", Null, False)
           Wait For Msgbox_Result (Result As Int)
           If Result = DialogResponse.POSITIVE Then
               RequestProductsInformation
           End If
       Else
           RequestProductsInformation
       End If
   End If
End Sub

Public Sub RequestProductsInformation
    ProgressDialogShow2(Starter.language.Value("strPleaseWait"), True)
    Starter.billmanager.GetInventoryInformation(Array(Starter.Product_1year, Starter.Product_6month, Starter.Product_1month ))
End Sub

Public Sub billmanager_InventoryCompleted (Success As Boolean, Products As List)
    If Success Then
        Dim mp As Map
        mp.Initialize

        For Each sk As SkuDetails In Products           
            Select sk.Sku
                Case Starter.Product_1year
                    mp.Put(Starter.Product_1year, sk.Price)
                Case Starter.Product_6month
                    mp.Put(Starter.Product_6month, sk.Price)
                Case Starter.Product_1month
                    mp.Put(Starter.Product_1month, sk.Price)
            End Select
        Next

        CallSub2(Me, "ShowInAppBilling", mp)
    End If
    ProgressDialogHide
End Sub

Private Sub ShowInAppBilling(LocalizedPrice As Map)
...
End Sub
 

Filippo

Expert
Licensed User
You are setting the Cancelable parameter in the call to ProgressDialogShow2 to true. This means that the user can cancel the dialog and quickly click on the button again. This will cause two requests to be sent.
WOW! How easy is the solution?
Thanks Erel :)
 
Top