(in starter module)
Sub CheckForGooglePlayServices As Boolean
Try
Dim GoogleApiAvailablity As JavaObject
GoogleApiAvailablity = GoogleApiAvailablity.InitializeStatic("com.google.android.gms.common.GoogleApiAvailability").RunMethod("getInstance", Null)
Dim context As JavaObject
context.InitializeContext
If 0<> GoogleApiAvailablity.RunMethod("isGooglePlayServicesAvailable", Array(context)) Then
GoogleApiAvailablity.RunMethod("makeGooglePlayServicesAvailable", Array(context))
Return False
End If
Return True
Catch
Return False
End Try
End Sub
Sub RestorePurchases
If CheckForGooglePlayServices Then
billing.Initialize("billing")
Wait For (billing.ConnectIfNeeded) Billing_Connected (Result As BillingResult)
If Result.IsSuccess Then
Wait For (billing.QueryPurchases("inapp")) Billing_PurchasesQueryCompleted (Result As BillingResult, Purchases As List)
'Log("Query completed: " & Result.IsSuccess)
If Result.IsSuccess Then
Dim found As Boolean=False
For Each p As Purchase In Purchases
If p.Sku = Main.productid Then
found=True
HandleAdsPurchase(p,"restorepurchases")
End If
Next
If found=False Then
CallSub(Main,Main.revokesub)
End If
End If
End If
End If
End Sub
(in main)
Sub startbilling
Wait For (Starter.billing.ConnectIfNeeded) Billing_Connected (Result As BillingResult)
If Result.IsSuccess Then
'get the sku details
Dim sf As Object = Starter.billing.QuerySkuDetails("inapp", Array(productid))
Wait For (sf) Billing_SkuQueryCompleted (Result As BillingResult, SkuDetails As List)
If Result.IsSuccess And SkuDetails.Size = 1 Then
'start the billing process. The PurchasesUpdated event will be raised in the starter service
Dim sku As SkuDetails=SkuDetails.Get(0)
Result = Starter.billing.LaunchBillingFlow(sku)
If Result.IsSuccess Then
Return
End If
End If
End If
ToastMessageShow("Error starting billing process", True)
End Sub