Android Question SERVICE_DISCONNECTED when calling LaunchBillingFlow

pacpinto

Member
Licensed User
Hi,

I've been developing an app using the in-app-purchases library:

https://www.b4x.com/android/forum/threads/googleplaybilling-in-app-purchases.109945/

I am able to connect, get purchases and query SKUs, but am now stuck when trying to buy a SKU. This code

B4X:
Sub buy_sku(sku As String)
    Wait For (Starter.billing.ConnectIfNeeded) Billing_Connected (Result As BillingResult)
    If Result.IsSuccess Then
        Dim sf As Object = Starter.billing.QuerySkuDetails("inapp", Array(sku))
        Wait For (sf) Billing_SkuQueryCompleted (Result As BillingResult, SkuDetails As List)
        If Result.IsSuccess And SkuDetails.Size = 1 Then
            Result = Starter.billing.LaunchBillingFlow(SkuDetails.Get(0))
            If Result.IsSuccess Then Return
        End If
    End If
    ToastMessageShow("Error starting billing process", True)
End Sub

is always returning this:

BillingResult IsSuccess = False, ResponseCode = SERVICE_DISCONNECTED
Debug string: Service connection is disconnected.

This is actually returned twice, once from the LaunchBillingFlow call and again in the PurchasesUpdated event (which gets called anyway?).
I am sure the SKU is correct. Any help at all would be greatly appreciated.

Thank you in advance!
 
Last edited:

pacpinto

Member
Licensed User
Ok, fixed it myself. Just in case anyone has the same issue, here's the fix.
After adding the line

B4X:
CreateResourceFromFile(Macro, GooglePlayBilling.GooglePlayBilling)

in the manifest editor, it now works like a charm.
Maybe there should be a mention of this somewhere in the library documentation...
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Maybe there should be a mention of this somewhere in the library documentation...
This is step #1:

1604210239143.png


 
Upvote 0

pacpinto

Member
Licensed User
Ooops I'm very sorry. Looks like I had a temporary blindness or something, maybe caused by too much work!
I even went back to your post to double check before posting. Anyway I am truly sorry I didn't read it right yesterday, it would have saved me hours of fiddling around.
 
Upvote 0
Top