Search in sources :

Example 6 with BillingClientStateListener

use of com.android.billingclient.api.BillingClientStateListener in project apcupsd-monitor by norkator.

the class MainMenu method initInAppBilling.

// ---------------------------------------------------------------------------------------------
/* In app billing features */
// Initialize in app billing feature
private void initInAppBilling() {
    // In app billing
    mBillingClient = BillingClient.newBuilder(this).enablePendingPurchases().setListener(this).build();
    mBillingClient.startConnection(new BillingClientStateListener() {

        @Override
        public void onBillingSetupFinished(BillingResult billingResult) {
            if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.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.
        }
    });
}
Also used : BillingClientStateListener(com.android.billingclient.api.BillingClientStateListener) BillingResult(com.android.billingclient.api.BillingResult)

Aggregations

BillingClientStateListener (com.android.billingclient.api.BillingClientStateListener)6 BillingResult (com.android.billingclient.api.BillingResult)4 BillingClient (com.android.billingclient.api.BillingClient)2 Nullable (androidx.annotation.Nullable)1 PurchasesResult (com.android.billingclient.api.Purchase.PurchasesResult)1 PurchasesUpdatedListener (com.android.billingclient.api.PurchasesUpdatedListener)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 DonationFragment (sk.henrichg.phoneprofiles.DonationFragment)1 DonationFragment (sk.henrichg.phoneprofilesplus.DonationFragment)1