1

I am trying to integrate In app billing v3 in my app. I call the following function to initialize.

public static void SetupInappBilling()
{
    mHelper = new IabHelper(context, base64EncodedPublicKey);
    mHelper.enableDebugLogging(true);
    mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() 
    {
        public void onIabSetupFinished(IabResult result) 
        {
            if (result.isSuccess())
            {
                Log.e("tag", "connected");
                ConnectionEstablished = true;

            } 
            else
            {
                    Log.e("tag", "not connected");

                    ConnectionEstablished = false;
                }
            }
        });
    }

but i dont get call back in OnIabSetupFinishedListener Can anyone tell me how to fix this issue

glo
  • 1,408
  • 3
  • 25
  • 54
  • How do you conclude that a Warning about Google Analytics relates to you not receiving an in-app billing event? – class stacker Feb 18 '13 at 10:41
  • Because i was not getting them before i started implementing in app billing and i have not explicitly called google analytics anywhere in my application – glo Feb 18 '13 at 10:42
  • Google Analytics is not involved in IAB as far as I know/have observed. Either way, please see it independently. -- But you _do_ call _SetupInappBilling()_? And in what Thread and Context do you do that? – class stacker Feb 18 '13 at 11:11
  • I call SetupInappBilling() from OnCreate() function – glo Feb 18 '13 at 11:17
  • And the device has connectivity? And there are no messages which _really_ relate to the IAB? The IAB will not work under certain conditions. Do you check the return value of _startSetup()_? I'm willing to bet you can't connect to the service even. – class stacker Feb 18 '13 at 11:30
  • I have internet connectivity and have INTERNET permission. I am not getting call back to listner given in startSetup(). – glo Feb 18 '13 at 11:34
  • But what about the return value of _startSetup()_? According to the code, you ignore it. It will fail e.g. if you're running on a regular AVD or if no Google Play account is set up. – class stacker Feb 18 '13 at 11:39
  • I am running on a device and return type of startSetup() is void. The only log i get related to IAB is `02-18 17:07:54.248: D/IabHelper(6862): Starting in-app billing setup.` – glo Feb 18 '13 at 11:41
  • I'm sorry. You're right. -- Umm, the example implementation ***** is somewhat incomplete. I highly recommend checking the boolean result of the _bindService()_ call at the end of _IabHelper.startSetup()_. You could return that as the result of startSetup() for example. If it's false, the bind operation failed and no callbacks will ever get called. – class stacker Feb 18 '13 at 11:48
  • boolean result of the bindService() is false. Any idea on what might be going wrong. – glo Feb 18 '13 at 12:01
  • That's what I thought. Please see my answer. I would suspect that your device doesn't support IAB V3? – class stacker Feb 18 '13 at 12:11

1 Answers1

3

As discussed, the example IabHelper implementation ignores the return value of the bindService() call.

bindService() returns false if it cannot bind to the Service. In this case, no callbacks will ever get called. In this respect, the return value of bindService() is essential for the program logic and should never be ignored; the example application is not exactly perfect here.

If I recall this correctly, conditions where binding to the IAB V3 will not work are:

  • Only IAB V2 is available (it uses a different class name)
  • Google Play is not fully set up
class stacker
  • 5,357
  • 2
  • 32
  • 65