- Qt 6.8
- Demo Android Classes
- Qt 6.8.3 Reference Documentation

# Demo Android Classes

## Classes

AndroidInAppProduct | A product registered in the store.
AndroidInAppTransaction | Contains information about a transaction in the external app store.
AndroidInAppPurchaseBackend | Comminucates with external store.
`androidjni.cpp` and `InAppPurchase.java` | Communication between Google Play's billing system and C++.

Check out Base Classes

## AndroidInAppProduct

AndroidInAppProduct adds purchase() for initializing purchasing process.

## AndroidInAppTransaction

AndroidInAppTransaction is created in the AndroidInAppPurchaseBackend using purchaseSucceeded(), purchaseFailed() and checkFinalizationStatus().

AndroidInAppTransaction adds new parameters and return types. Class has finalize() function that separates Consumable and Unlockable products to be either acknowledged or consumed in the InAppPurchase.java.

## AndroidInAppPurchaseBackend

AndroidInAppPurchaseBackend makes and receives calls from InAppPurchase.java. This class is one of the back end components in the application.

### Initialize

Shows the products information on the store page.

1. AndroidInAppPurchaseBackend is called from InAppStore::setupBackend().
2. At initialization AndroidInAppPurchaseBackend will give Context and pointer of its self to the Java in the calls constructor and then initializes the connection to the Google Play store using the initialize() function.
3. When the connection is successful, androidjni will call registerRedy() which emits the ready() signal to InAppStore and starts queryProducts() function to get the information of the purchasable items.
4. When the query is done, productQueryDone() signal is emitted and the item's information will be visible on the application's store page.

### Purchasing

When pressing one of the products on the applications store page a call is routed through `AndroidInAppProduct::purchase()` to purchaseProduct() function. This then calls the Java method launchBillingFlow() which opens Goole Plays billing flow to the user.

## InAppPurchase.java and androidjni.cpp

AndroidInAppPurchaseBackend makes calls directly to `InAppPurchase.java` and receives Java calls from androidjni. The demo application communicates with Java function using QJniObject.

See also Integrate the Google Play Billing Library, QJniObject, and QJniEnvironment.