HBHBHB / marketbilling

Automatically exported from code.google.com/p/marketbilling
0 stars 0 forks source link

Dialog does not appear on first request #120

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
This happens randomly, but in most cases the first request to open Google 
Billing dialog is ignored, each next works perfectly, until app is restarted 
again

OS VERSION: Android 2.3

DEVICE: LG P500

By tracking code execution using Log I've discovered that service is connected 
and pending requests are executed before current (first) request was added to 
pending queue like this:

public boolean runRequest() {
            //this is ignored on first connection
            if (runIfConnected()) {
                return true;
            }

            if (bindToMarketBillingService()) {//create service which gets executes immediately 
            //and also executes onServiceConnected event which executes runPendingRequests()
                // Only after that current request is added to pending queue thus it never gets executed
                mPendingRequests.add(this);
                return true;
            }
            return false;
        }

The solution would be to add current request to queue before binding service 
like this:

 public boolean runRequest() {
            //if there is already a service we get in this if statement
            if (runIfConnected()) {
                return true;
            }
            //else we add the request to queue
            mPendingRequests.add(this);
            //and only then try to bind the service
            if (bindToMarketBillingService()) {
                return true;
            }
            return false;
        }

Original issue reported on code.google.com by ar2rsawseen on 4 May 2013 at 4:31

GoogleCodeExporter commented 8 years ago
All that happens inside BillingService.java

Original comment by ar2rsawseen on 4 May 2013 at 4:36