• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BillingClientStateListener类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.android.billingclient.api.BillingClientStateListener的典型用法代码示例。如果您正苦于以下问题:Java BillingClientStateListener类的具体用法?Java BillingClientStateListener怎么用?Java BillingClientStateListener使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BillingClientStateListener类属于com.android.billingclient.api包,在下文中一共展示了BillingClientStateListener类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: showDonateGooglePlay

import com.android.billingclient.api.BillingClientStateListener; //导入依赖的package包/类
private void showDonateGooglePlay() {
    mBillingClient = BillingClient.newBuilder(this).setListener(this).build();

    mBillingClient.startConnection(new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(@BillingResponse int billingResponseCode) {
            if (billingResponseCode == BillingResponse.OK) {
                // The billing client is ready. You can query purchases here.
                BillingFlowParams flowParams = BillingFlowParams.newBuilder()
                        .setSku("donate_2")
                        .setType(SkuType.INAPP)
                        .build();
                int responseCode = mBillingClient.launchBillingFlow(MainActivity.this, flowParams);
            }
        }
        @Override
        public void onBillingServiceDisconnected() {
            // Try to restart the connection on the next request to
            // Google Play by calling the startConnection() method.
        }
    });
}
 
开发者ID:RikkaApps,项目名称:FCM-for-Mojo,代码行数:23,代码来源:MainActivity.java


示例2: BillingManager

import com.android.billingclient.api.BillingClientStateListener; //导入依赖的package包/类
public BillingManager(Activity activity) {
    mActivity = activity;
    mBillingClient = BillingClient.newBuilder(mActivity).setListener(this).build();
    mBillingClient.startConnection(new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(@BillingClient.BillingResponse int billingResponse) {
            if (billingResponse == BillingClient.BillingResponse.OK) {
                Log.i(TAG, "onBillingSetupFinished() response: " + billingResponse);
            } else {
                Log.w(TAG, "onBillingSetupFinished() error code: " + billingResponse);
            }
        }
        @Override
        public void onBillingServiceDisconnected() {
            Log.w(TAG, "onBillingServiceDisconnected()");
        }
    });
}
 
开发者ID:googlecodelabs,项目名称:play-billing-codelab,代码行数:19,代码来源:BillingManager.java


示例3: startServiceConnection

import com.android.billingclient.api.BillingClientStateListener; //导入依赖的package包/类
private void startServiceConnection(final Runnable executeOnSuccess) {
    billingClient.startConnection(new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(int responseCode) {
            Log.i(TAG, "Billing setup finished. Response code: " + responseCode);

            if (responseCode == BillingClient.BillingResponse.OK) {
                serviceConnected = true;
                if (executeOnSuccess != null) {
                    executeOnSuccess.run();
                }
            }
        }

        @Override
        public void onBillingServiceDisconnected() {
            Log.i(TAG, "Billing service disconnected");
            serviceConnected = false;
        }
    });
}
 
开发者ID:steevp,项目名称:UpdogFarmer,代码行数:22,代码来源:BillingManager.java


示例4: startServiceConnection

import com.android.billingclient.api.BillingClientStateListener; //导入依赖的package包/类
public void startServiceConnection(final Runnable executeOnSuccess) {
    mBillingClient.startConnection(new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(@BillingResponse int billingResponseCode) {
            Log.d(TAG, "Setup finished. Response code: " + billingResponseCode);

            if (billingResponseCode == BillingResponse.OK) {
                mIsServiceConnected = true;
                if (executeOnSuccess != null) {
                    executeOnSuccess.run();
                }
            }
            mBillingClientResponseCode = billingResponseCode;
        }

        @Override
        public void onBillingServiceDisconnected() {
            mIsServiceConnected = false;
        }
    });
}
 
开发者ID:uthayacloud,项目名称:AndroidInAppBilling,代码行数:22,代码来源:BillingManager.java


示例5: startServiceConnection

import com.android.billingclient.api.BillingClientStateListener; //导入依赖的package包/类
public void startServiceConnection(final Runnable executeOnSuccess) {
    billingClient.startConnection(new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(@BillingResponse int billingResponseCode) {
            Log.d(TAG, "Setup finished. Response code: " + billingResponseCode);

            if (billingResponseCode == BillingResponse.OK) {
                isServiceConnected = true;
                if (executeOnSuccess != null) {
                    executeOnSuccess.run();
                }
            }
            billingClientResponseCode = billingResponseCode;
        }

        @Override
        public void onBillingServiceDisconnected() {
            isServiceConnected = false;
        }
    });
}
 
开发者ID:plusCubed,项目名称:velociraptor,代码行数:22,代码来源:BillingManager.java


示例6: onResume

import com.android.billingclient.api.BillingClientStateListener; //导入依赖的package包/类
@Override
protected void onResume() {
  super.onResume();
  billingClient = new BillingClient.Builder(this).setListener(this).build();
  billingClient.startConnection(
      new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(@BillingResponse int billingResponseCode) {
          if (billingResponseCode == BillingResponse.OK) {
            Purchase.PurchasesResult purchasesResult =
                billingClient.queryPurchases(BillingClient.SkuType.INAPP);
            onPurchasesUpdated(
                purchasesResult.getResponseCode(), purchasesResult.getPurchasesList());
          }
        }

        @Override
        public void onBillingServiceDisconnected() {}
      });
}
 
开发者ID:peterjosling,项目名称:scroball,代码行数:21,代码来源:MainActivity.java


示例7: startServiceConnectionIfNeeded

import com.android.billingclient.api.BillingClientStateListener; //导入依赖的package包/类
/**
 * Trying to restart service connection if it's needed or just execute a request.
 * <p>Note: It's just a primitive example - it's up to you to implement a real retry-policy.</p>
 * @param executeOnSuccess This runnable will be executed once the connection to the Billing
 *                         service is restored.
 */
private void startServiceConnectionIfNeeded(final Runnable executeOnSuccess) {
    if (mBillingClient.isReady()) {
        if (executeOnSuccess != null) {
            executeOnSuccess.run();
        }
    } else {
        mBillingClient.startConnection(new BillingClientStateListener() {
            @Override
            public void onBillingSetupFinished(@BillingResponse int billingResponse) {
                if (billingResponse == BillingResponse.OK) {
                    Log.i(TAG, "onBillingSetupFinished() response: " + billingResponse);
                    if (executeOnSuccess != null) {
                        executeOnSuccess.run();
                    }
                } else {
                    Log.w(TAG, "onBillingSetupFinished() error code: " + billingResponse);
                }
            }

            @Override
            public void onBillingServiceDisconnected() {
                Log.w(TAG, "onBillingServiceDisconnected()");
            }
        });
    }
}
 
开发者ID:googlecodelabs,项目名称:play-billing-codelab,代码行数:33,代码来源:BillingManager.java


示例8: BillingManager

import com.android.billingclient.api.BillingClientStateListener; //导入依赖的package包/类
public BillingManager(Activity activity) {
    mActivity = activity;
    mBillingClient = BillingClient.newBuilder(mActivity).setListener(this).build();
    mBillingClient.startConnection(new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(@BillingResponse int billingResponse) {
            Log.i(TAG, "onBillingSetupFinished() response: " + billingResponse);
        }
        @Override
        public void onBillingServiceDisconnected() {
            Log.w(TAG, "onBillingServiceDisconnected()");
        }
    });
}
 
开发者ID:googlecodelabs,项目名称:play-billing-codelab,代码行数:15,代码来源:BillingManager.java


示例9: startServiceConnection

import com.android.billingclient.api.BillingClientStateListener; //导入依赖的package包/类
/**
 * Trying to restart service connection.
 * <p>Note: It's just a primitive example - it's up to you to develop a real retry-policy.</p>
 * @param executeOnSuccess This runnable will be executed once the connection to the Billing
 *                         service is restored.
 */
private void startServiceConnection(final Runnable executeOnSuccess) {
    mBillingClient.startConnection(new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(@BillingResponse int billingResponse) {
            Log.i(TAG, "onBillingSetupFinished() response: " + billingResponse);
        }
        @Override
        public void onBillingServiceDisconnected() {
            Log.w(TAG, "onBillingServiceDisconnected()");
        }
    });
}
 
开发者ID:googlecodelabs,项目名称:play-billing-codelab,代码行数:19,代码来源:BillingManager.java


示例10: startBuyProcess

import com.android.billingclient.api.BillingClientStateListener; //导入依赖的package包/类
public void startBuyProcess(){
    final BillingClient mBillingClient;

    mBillingClient = BillingClient.newBuilder(getActivity().getApplicationContext()).setListener(this).build();
    mBillingClient.startConnection(new BillingClientStateListener() {
        @Override
        public void onBillingSetupFinished(@BillingClient.BillingResponse int billingResponseCode) {
            if (billingResponseCode == BillingClient.BillingResponse.OK) {
                // The billing client is ready
                final SharedPreferences settings = getActivity().getSharedPreferences(PREFS_NAME, 0);
                boolean donationPurchased = settings.getBoolean("donationPurchased", false);
                if(!donationPurchased){
                    // Start buy process
                    BillingFlowParams flowParams = BillingFlowParams.newBuilder()
                            .setSku("donation_upgrade")
                            .setType(BillingClient.SkuType.INAPP)
                            .build();
                    // Launch purchase
                    mBillingClient.launchBillingFlow(getActivity(), flowParams);
                }
            }
        }

        @Override
        public void onBillingServiceDisconnected() {
            // Try to restart the connection on the next request to
            // Google Play by calling the startConnection() method.
            if(getView() != null) {
                Snackbar.make(getView(), R.string.donation_cancelled, Snackbar.LENGTH_SHORT).show();
            }
        }
    });
}
 
开发者ID:systemallica,项目名称:ValenBisi,代码行数:34,代码来源:DonateFragment.java



注:本文中的com.android.billingclient.api.BillingClientStateListener类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java PreparedUpdate类代码示例发布时间:2022-05-22
下一篇:
Java Roster类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap