Android Question GooglePlayBilling: LaunchBillingFlow from any activity?

divinglog

Member
Licensed User
Longtime User
Hello

I'm using the GooglePlayBilling library and if I understand it correctly, I can call LaunchBillingFlow only from the activity which has initialized the BillingClient object, right? At least this is the only place where it works for me. Calling this from another activity does nothing. Is there a way to launch the billing flow from any activity in my app?

Thank you!
 

Xandoca

Active Member
Licensed User
Longtime User
if you are using B4XPages project you can call from any page using:
B4X:
    Dim page As B4XMainPage = B4XPages.GetPage("MainPage")
    Wait For (page.billing.ConnectIfNeeded) Billing_Connected (Result As BillingResult)

Billing is declared at B4XMainPage.
 
Upvote 0

divinglog

Member
Licensed User
Longtime User
No sorry, I don't use B4XPages in my app. It's an existing app with several activities and I'm switching from the older in-app billing library.
 
Upvote 0

divinglog

Member
Licensed User
Longtime User
Thank you Erel! After a few tests I'm now using 2 BillingClient objects, which seem to work fine: one during app start to check for owned products and another one from the in-app purchase activity where I'm listing all products and LaunchBillingFlow is called. I just have to make sure to refresh the other one so they're in sync after the user purchased an item. Seems to be working now as I want.
 
Upvote 0
Top