演示 Android 课程

AndroidInApp 产品在商店中注册的产品。
AndroidInApp 交易包含外部应用程序商店中的交易信息。
应用程序购买后台与外部商店通信。
androidjni.cppInAppPurchase.javaGoogle Play 计费系统与 C++ 之间的通信。

查看基类

AndroidInAppProduct

AndroidInAppProduct 添加了用于初始化购买流程的 purchase()。

AndroidInAppTransaction

AndroidInAppTransaction 是在 AndroidInAppPurchaseBackend 中使用 purchaseSucceeded()、purchaseFailed() 和 checkFinalizationStatus() 创建的。

AndroidInAppTransaction 增加了新的参数和返回类型。该类具有 finalize() 函数,可在 InAppPurchase.java 中将消耗品和解锁品分开,以便确认或消耗。

AndroidInAppPurchaseBackend

AndroidInAppPurchaseBackend 从 InAppPurchase.java 发起和接收调用。该类是应用程序的后端组件之一。

初始化

在商店页面上显示产品信息。

  1. AndroidInAppPurchaseBackend 由 InAppStore::setupBackend() 调用。
  2. 初始化时,AndroidInAppPurchaseBackend 会在调用构造函数时向 Java 提供Context和自身指针,然后使用 initialize() 函数初始化与 Google Play 商店的连接。
  3. 连接成功后,androidjni 将调用 registerRedy(),向 InAppStore 发送 ready() 信号,并启动 queryProducts() 函数获取可购买项目的信息。
  4. 查询完成后,productQueryDone() 信号将发出,物品信息将在应用程序的商店页面上显示。

购买

点击应用程序商店页面上的产品时,会通过AndroidInAppProduct::purchase() 调用 purchaseProduct() 函数。然后调用 Java 方法 launchBillingFlow(),向用户打开 Goole Plays 账单流。

InAppPurchase.java 和roidjni.cpp

AndroidInAppPurchaseBackend 直接调用InAppPurchase.java 并接收来自 androidjni 的 Java 调用。演示应用程序使用QJniObject 与 Java 函数通信。

另请参阅 集成 Google Play 计费库QJniObjectQJniEnvironment

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.