protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { // Ask the in-app purchasing service connection's billing handler to process this request InAppService inAppService = App.ViewModel.TheInAppService as InAppService; inAppService.HandleActivityResult(requestCode, resultCode, data); }
protected override void OnDestroy() { // Disconnect from the in-app purchasing service InAppService inAppService = App.ViewModel.TheInAppService as InAppService; inAppService.OnDestroy(); base.OnDestroy(); }
/// <summary> /// /// </summary> /// <param name="name"></param> /// <param name="service"></param> public void OnServiceConnected(ComponentName name, IBinder service) { try { Connected = true; InAppService = InAppBillingServiceStub.AsInterface(service); var packageName = MainContext.PackageName; Utils.LogDebug("InAppService connected. Checking for v3 support."); if (InAppService.IsBillingSupported(3, packageName, Consts.ITEM_TYPE_INAPP) != Consts.BILLING_RESPONSE_RESULT_OK) { //If in-app items are not supported, subscriptions are not as well. PurchasesSupported = SubscriptionsSupported = false; return; } PurchasesSupported = true; Utils.LogDebug("InAppService v3 is supported."); if (InAppService.IsBillingSupported(3, packageName, Consts.ITEM_TYPE_SUBS) != Consts.BILLING_RESPONSE_RESULT_OK) { Utils.LogDebug("Subscriptions are not available."); SubscriptionsSupported = true; } else { Utils.LogDebug("Subscriptions are not available."); } if (m_listener != null) { m_listener.Connected(); } } catch (RemoteException e) { Utils.LogError("Remote exception occurred in OnServiceConnected; " + e.ToString()); Connected = false; } finally { //Just indicates that the connect request has completed // check PurchasesSupported to know whether or not v3 is supported, if successful if (m_connectTcs != null) { m_connectTcs.SetResult(this.Connected); } } }
/// <summary> /// Invoked when the InAppService is disconnected /// </summary> /// <param name="name"></param> public void OnServiceDisconnected(ComponentName name) { this.Connected = false; Utils.LogDebug("InAppService disconnected."); //The following will get re-initialized in OnServiceConnected if (this.InAppService != null) { InAppService.Dispose(); InAppService = null; } if (m_listener != null) { m_listener.Disconnected(); } }
/// <summary> /// Dispose of all un-managed resources and unbind the service connection /// </summary> /// <param name="disposing"></param> protected override void Dispose(bool disposing) { base.Dispose(disposing); Utils.LogDebug("Disposing."); if (MainContext != null) { MainContext.UnbindService(this); } if (this.InAppService != null) { InAppService.Dispose(); InAppService = null; } if (m_listener != null && this.Connected) { m_listener.Disconnected(); } this.Connected = false; }