Search code examples
androidandroid-studiobilling

Billing client is always reached


I am executing the code described by the google billing library, but my device always connects to the billing client, also if I m in flight mode.

//Initiate billing client
        bc = BillingClient.newBuilder(getApplicationContext()).setListener(this).
enablePendingPurchases().build();
        bc.startConnection(new BillingClientStateListener() {
            @Override
            public void onBillingSetupFinished(BillingResult billingResult) {
                if (billingResult.getResponseCode() ==  BillingClient.BillingResponseCode.OK) {
                    // The BillingClient is ready. You can query purchases here.
                    Toast.makeText(getApplicationContext(), "Connected", Toast.LENGTH_SHORT).show();
                }
            }
            @Override
            public void onBillingServiceDisconnected() {
                // Try to restart the connection on the next request to
                // Google Play by calling the startConnection() method.
                Toast.makeText(getApplicationContext(), "Failure", Toast.LENGTH_SHORT).show();
            }
        });

Solution

  • Google Play services cache purchases, so it is available offline