/// <summary> /// Starts the setup process. This will start up the setup process asynchronously. /// You will be notified through the listener when the setup process is complete. /// This method is safe to call from a UI thread. /// </summary> /// <param name="listener"> The listener to notify when the setup process is complete. </param> public void startSetup(OnIabSetupFinishedListener listener) { // If already set up, can't do it again. checkNotDisposed(); if (mSetupDone) { throw new IllegalStateException("IAB helper is already set up."); } // Connection to IAB service logDebug("Starting in-app billing setup."); mServiceConn = new ServiceConnectionAnonymousInnerClassHelper(this, listener); Intent serviceIntent = new Intent("com.android.vending.billing.InAppBillingService.BIND"); serviceIntent.SetPackage("com.android.vending"); var list = mContext.PackageManager.QueryIntentServices(serviceIntent, 0); if ((list == null) ? false : list.Any()) { // service available to handle that Intent mContext.BindService(serviceIntent, mServiceConn, Bind.AutoCreate); } else { // no service available to handle that Intent if (listener != null) { listener.onIabSetupFinished(new IabResult(BILLING_RESPONSE_RESULT_BILLING_UNAVAILABLE, "Billing service unavailable on device.")); } } }
public ServiceConnectionAnonymousInnerClassHelper(IabHelper outerInstance, OnIabSetupFinishedListener listener) { this.outerInstance = outerInstance; this.listener = listener; }