Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- BillingClient billingClient = BillingClient.newBuilder(getApplicationContext()).setListener(new PurchasesUpdatedListener() {
- @Override
- public void onPurchasesUpdated(int responseCode, @Nullable List<Purchase> purchases) {
- if(responseCode == BillingClient.BillingResponse.OK) {
- //Do something
- }
- }
- }).build();
- billingClient.startConnection(new BillingClientStateListener() {
- @Override
- public void onBillingSetupFinished(int responseCode) {
- if(responseCode == BillingClient.BillingResponse.OK) {
- //Response is OK and working fine
- }
- }
- @Override
- public void onBillingServiceDisconnected() {
- //Do something
- }
- });
- billingClient.queryPurchaseHistoryAsync(BillingClient.SkuType.INAPP, new PurchaseHistoryResponseListener() {
- @Override
- public void onPurchaseHistoryResponse(int responseCode, List<Purchase> purchasesList) {
- if(responseCode == BillingClient.BillingResponse.OK) {
- //Always returning 0 size() of purchasesList
- Toast.makeText(getApplicationContext(), "There are " + purchasesList.size() + " items you've purchased.", Toast.LENGTH_LONG).show();
- }
- }
- });
Add Comment
Please, Sign In to add comment