Langsung ke konten

Paling sering dikunjungi

Terakhir dikunjungi


Establishing In-app Billing Products for Sale

Before publishing your In-app Billing app, you must define the product list of digital goods available for purchase in the Google Play Console.

Specify in-app products in Google Play

From the Play Console, you can define product information for in-app products and associate a product list with your app.

To add new in-app products to your product list:

  1. Build a signed APK file for your In-app Billing app. To learn how to build and sign your APK, see Prepare for Release.
  2. In the Play Console, open the app entry that you created earlier.
  3. Click on the App releases in the left-hand menu and create a release to upload your APK. You can use any channel you want, and you can start with Beta or Alpha if you don't want to publish the app now. Check our support page for details on how to Prepare & rollout releases.
  4. Navigate to the uploaded app listing, and click on In-app Products.
  5. Click on the option to add a new product, then complete the form to specify the product information such as the item's unique product ID, also called its SKU, as well as a description, price, and country availability. Note down the product ID as you may need this information to query purchase details in your app later. To see a list of the products used by the TrivialDrive_v2 sample, review the UiDelegatesFactory class.

Note: The In-app Billing service only supports managed in-app products, so make sure that you specify that the purchase type is 'Managed' when you add new items to your product list in the Play Console.

  1. Once you have completed the form, activate the product so that your app can purchase it.

Query items available for purchase

You can query Google Play to programmatically retrieve details of the in-app products that are associated with your app, such as a product's price, title, description, and type. This query is useful, for example, when you want to display a listing of unowned items that are still available for purchase to users.

Note: When making a query, you must specify the product IDs for the products explicitly. You can manually find the product IDs from the Play Console by opening the In-app Products menu for your app. The product IDs are listed under the column labeled Name/ID.

To retrieve the product details, call the asynchronous querySkuDetailsAsync() method and pass it a reference to a listener that implements the SkuDetailsResponseListener interface and a reference to a SkuDetailsParams object with a SKU list and item type. The following code shows how you can integrate this method into the BillingManager class:

public void querySkuDetailsAsync(SkuDetailParams params, final SkuDetailsResponseListener listener) {
    // Create a runnable from the request to use inside the connection retry policy.
    Runnable queryRequest = new Runnable() {
        public void run() {
            // Create the SkuDetailParams object
            SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
            // Run the query asynchronously.
            mBillingClient.querySkuDetailsAsync(, new SkuDetailsResponseListener() {
                        public void onSkuDetailsResponse(SkuDetailsResult result) {


You must implement a retry policy to handle possible interruptions to the connection between the Play Billing Library client and the In-app Billing service. You can add a generic retry mechanism to the BillingManager class that accepts the Runnable object from the previous code sample as follows:

private void executeServiceRequest(Runnable runnable) {
    if (mIsServiceConnected) {;
    } else {
        // If the billing service disconnects, try to reconnect once.

If the asynchronous query is successful, the query results are stored in a List of SkuDetails objects that is passed back to the listener. The following sample code shows how you can call the querySkuDetailsAsync() method in the BillingManager class from your UI and pass it a reference to an object that implements the SkuDetailsResponseListener interface:

private void addSkuRows(final List<SkuRowData> inList, List<String> skusList,
        final @SkuType String billingType, final Runnable executeWhenFinished) {

    mBillingProvider.getBillingManager().querySkuDetailsAsync(billingType, skusList,
            new SkuDetailsResponseListener() {
                public void onSkuDetailsResponse(@BillingResponse int responseCode,
                                                                         List<SkuDetails> skuDetailsList) {

                    if (result.getResponseCode() != BillingResponse.OK) {
                        // Handle any error responses.
                    } else if (skuDetailsList != null
                            && skuDetailsList.size() > 0) {
                            // Traverse through the list of SKUs inside SkuDetailsList.
Situs ini menggunakan cookies untuk menyimpan preferensi Anda tentang bahasa di situs tertentu dan opsi tampilan.

Dapatkan berita dan tips terbaru dari developer Android yang akan membantu Anda mencapai kesuksesan di Google Play.

* Wajib Diisi


Ikuti Google Developers di WeChat

Buka situs ini dalam bahasa ?

Anda meminta halaman dalam bahasa , namun preferensi bahasa untuk situs ini adalah .

Ingin mengubah preferensi bahasa dan mengakses situs ini dalam bahasa ? Jika nanti Anda ingin mengubah preferensi bahasa, gunakan menu bahasa di bagian bawah setiap halaman.

Kelas ini memerlukan tingkat API atau yang lebih tinggi

Dokumen ini tersembunyi karena level API yang Anda pilih untuk dokumentasi ini adalah . Anda dapat mengubah level API dokumentasi dengan pemilih di atas menu navigasi sebelah kiri.

Untuk informasi lebih lanjut tentang menentukan level API yang diperlukan aplikasi Anda, baca Mendukung Versi Platform Yang Berbeda.

Take a short survey?
Help us improve the Android developer experience. (April 2018 — Developer Survey)