Last active
July 28, 2018 23:23
-
-
Save ponnamkarthik/828f8ff63d48a1f474fc62552010d999 to your computer and use it in GitHub Desktop.
In-app Billing Initalise
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BillingClient mBillingClient; | |
mBillingClient = BillingClient.newBuilder(this).setListener(new PurchasesUpdatedListener() { | |
@Override | |
public void onPurchasesUpdated(int responseCode, @Nullable List<Purchase> purchases) { | |
for(Purchase purchase: purchases) { | |
//When every a new purchase is made | |
} | |
} | |
}).build(); | |
mBillingClient.startConnection(new BillingClientStateListener() { | |
@Override | |
public void onBillingSetupFinished(@BillingClient.BillingResponse int billingResponseCode) { | |
if (billingResponseCode == BillingClient.BillingResponse.OK) { | |
// The billing client is ready. You can query purchases here. | |
} | |
} | |
@Override | |
public void onBillingServiceDisconnected() { | |
// Try to restart the connection on the next request to | |
// Google Play by calling the startConnection() method. | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
add