diff --git a/docs/html/distribute/googleplay/developer-console.jd b/docs/html/distribute/googleplay/developer-console.jd index c826e82ca6f2f..5a6c96fcb80ed 100644 --- a/docs/html/distribute/googleplay/developer-console.jd +++ b/docs/html/distribute/googleplay/developer-console.jd @@ -10,30 +10,30 @@ Xnonavpage=true

Features

    -
  1. Latest blog posts
  2. -
  3. Publish with confidence
  4. -
  5. Acquire users
  6. -
  7. Actionable insights
  8. -
  9. Manage your app
  10. +
  11. Latest Blog Posts
  12. +
  13. Publish with Confidence
  14. +
  15. Acquire Users
  16. +
  17. Learn about Users and App Performance
  18. +
  19. Manage Your App

- The Google Play Developer - Console is your home for publishing operations and tools. + The Google Play Developer + Console is your home for publishing and managing your apps.

- Upload apps, build your product pages, configure prices and distribution, and - publish. You can manage all phases of publishing on Google Play through the - Developer Console, from any web browser. + You can manage all phases of publishing on Google Play through the Developer + Console. Using any web browser, you can upload apps, build product pages, set + prices, configure distribution, and publish apps.

- Once you've registered and received verification by email, you can sign in to your Google Play Developer Console.

@@ -44,7 +44,7 @@ Xnonavpage=true
-

Latest blog posts

+

Latest Blog Posts

-

Publish with confidence

- +

Publish with Confidence

+

The Developer Console provides rich testing features and staged rollouts that help you to + provide apps that satisfy your users.

-

Alpha and beta tests

- -
-
-

- Distribute your pre-release app to users as an open beta with a - one-click, opt-in URL or as a closed beta using an email list, Google - Group, or Google+ community. Users can then provide feedback, while not - affecting your app’s public reviews and rating. This valuable feedback - will help you test features and improve the quality of your app. - Learn more. -

-
- -
- -
-

Cloud Test Lab

@@ -87,8 +66,8 @@ Xnonavpage=true

Get free automated testing of your app on physical devices covering nearly every brand, model, and version of the devices your users might - be using. The lab will help you quickly find compatibility issues you - may miss using only your available test devices. Sign-up in the + have. The lab helps you quickly find compatibility issues that you + might miss using only your available test devices. Sign up in the Developer Console to become an early tester before this feature becomes more widely available.

+

Alpha and beta tests

+ +
+
+

+ Collect user feedback on early versions of your app with alpha and beta testing. + Distribute your pre-release app to users as an open beta with a + one-click, opt-in URL or as a closed beta using an email list, Google + Group, or Google+ community. Users can provide feedback, while not + affecting your app’s public reviews and rating. This valuable feedback + helps you test features and improve the quality of your app. + Learn more. +

+
+ +
+ +
+
+

Staged rollouts

- Release app updates progressively to an increasing portion of your users and - monitor for missed issues. Then take the opportunity to fix problems before - all your users are affected. Learn more. + class="external-link">Learn more.

-

- Tip: If you find an issue during a rollout stage you can - halt the rollout to further minimize the effect, and then resume rollout once - a fix has been made. +

+ Tip: If you find an issue during a rollout stage, you can + halt the rollout, make the fix, and then resume.

-

Aquire users

- -

AdWords Universal App Campaigns

+

Acquire Users

+

Using the Developer Console, you can configure targeted ads to present your app to more users. + You can test variations of your Play Store listings and track user responses.

+

Promote your app with AdWords

- Easily and conveniently buy AdWords app install ads, across Search + Easily and conveniently buy AdWords app install ads. AdWords Universal App Campaigns + appear across Search (including Play Search), YouTube, AdMob, and the Google Display Network. - Simply set a budget and cost per acquisition and Google takes care of the + Set a budget and cost per acquisition, and Google takes care of the rest. Learn more.

-

Store Listing Experiments

+

Increase installs with improved store listings

-

- Test variations of the images and text used to promote and describe - your app on your Play store listing. Then when enough data has been - collected, choose to make the winning combination visible on Google +

With store listing experiments, + you can test variations of your app's Play Store listing. + You can try different combinations of images and text used to promote and describe + your app on its Play Store listing. Collect data, choose the best combination, and make + it visible on Google Play. Learn more.

-

- Tip: You can even try out different orders for your - screenshots and other images to discover which grabs users’ attention - the best. +

+ Tip: You can reorder your screenshots and other images in different ways + to determine the arrangement that best attracts users.

@@ -158,20 +165,21 @@ Xnonavpage=true
-

User Acquisition performance report

+

User acquisition performance report

- Discover where visitors to your Play Store listing come from, how many - go on to install your app, and how many buy your in-app products in the - User Acquisition performance report; compare cohorts, examine - acquisition channels, and see details of users and buyers. Learn more.

@@ -180,14 +188,16 @@ Xnonavpage=true
-

Actionable insights

- +

Learn about App Users and Performance

+

Using the Developer console, you can gain valuable insights about app performance. + You can better understand user behavior and find out ways to optimize your app.

Player Analytics

@@ -195,8 +205,10 @@ Xnonavpage=true

- With Google Play game services integration, discover more about the - behaviour of your game players; how they play and how they buy. Also get + Google Play game services offers a comprehensive dashboard of player and engagement + statistics. + With Player Analytics, discover more about the + behavior of your game users, including how they play and how they buy. Also get help setting and monitoring revenue budgets. Learn more.

@@ -206,7 +218,8 @@ Xnonavpage=true
@@ -216,74 +229,77 @@ Xnonavpage=true

- Get a wide range of reports on the performance of your app and behaviour - of users; such as installs, revenue, crashes, and more. Turn on email - alerts to be notified of any sudden changes to important stats. Learn more. + Get a wide range of reports on the performance of your app and behavior + of users such as installs, revenue, and crashes. Turn on email + alerts to receive notifications of any sudden changes to important stats. Learn more.

-

Optimization tips

+

Optimization tips

- Get tips, based on automatic app scanning, on ways in which you can improve - your app, everything from updating old APIs to suggestions for languages you - should consider localizing to. + Automatic app scanning provides tips on ways to improve your apps—everything + from updating old APIs to suggested languages for localization.

-

Manage your app

+

Manage Your App

Manage your APKs

Upload and manage your Android application packages (APK) to the Developer - Console as drafts or to your Alpha, Beta, or Production channels. Learn more. + class="external-link">Learn more.

-

- Tip: Ensure users get the best possible experience for the +

+ Tip: Ensure that users get the best possible experience for the smallest app downloads by creating multiple APKs with just the right content - for device screen size, hardware features and more. + for hardware features such as screen size. For more information about using multiple APKs, + see + Maintaining Multiple APKs.

In-app products and subscriptions

- Manage your in-app products and price them for local markets accordingly. - Offer weekly, monthly, annual, or seasonal subscriptions and take advantage - of features such as grace periods and trials. Learn more. + class="external-link">Learn more.

Pricing and distribution

- Control the price of your app for each country you choose to distribute to. - Make your app available to new audiences — opt-in to Android Auto, Android + Control the price of your app for each country that you distribute to. + Make your app available to new audiences—opt-in to Android Auto, Android TV, and Android Wear, as well as Designed for Families, Google Play for Work, and Google Play for Education. Learn more.

-

+ Note: When you distribute your app to countries that use other currencies, + the Google Play Developer Console autofills country-specific prices based on current exchange + rates and locally-relevant pricing patterns. You can update the exchange rates manually by + selecting Refresh exchange rates.

diff --git a/docs/html/google/play/billing/billing_overview.jd b/docs/html/google/play/billing/billing_overview.jd index a05cc8d769920..7d932b7058adf 100644 --- a/docs/html/google/play/billing/billing_overview.jd +++ b/docs/html/google/play/billing/billing_overview.jd @@ -7,19 +7,20 @@ parent.link=index.html

Quickview

In this document

  1. In-app Billing API
  2. In-app Products
      -
    1. Product Types +
    2. Product types
  3. Google Play Developer Console
  4. @@ -27,30 +28,33 @@ same look-and-feel as for app purchases.
  5. Sample App
  6. Migration Considerations
-

Related Samples

+

Related samples

  1. Sample Application (V3)
-

Related Videos

+

Related videos

    -
  1. Implementing +
  2. + Implementing Freemium
-

This documentation describes the fundamental In-app Billing components and +

This document describes the fundamental In-app Billing components and features that you need to understand in order to add In-app Billing features into your application.

-

Note: Ensure that you comply with applicable laws in the countries where you -distribute apps. For example, in EU countries, laws based on the - -Unfair Commercial Practices Directive prohibit direct exhortations to children to buy advertised -products or to persuade their parents or other adults to buy advertised products for them. -See the - +

Note: Ensure that you comply with applicable laws in the countries where + you distribute apps. For example, in EU countries, laws based on the + +Unfair Commercial Practices Directive prohibit direct exhortations to children to buy + advertised products or to persuade their parents or other adults to buy advertised products + for them. See the + position of the EU consumer protection authorities for more information on this and other topics.

@@ -61,75 +65,82 @@ exposed by the Google Play app that is installed on the device. The Google Play app then conveys billing requests and responses between your application and the Google Play server. In practice, your application never directly communicates with the Google Play server. Instead, your application -sends billing requests to the Google Play application over interprocess +sends billing requests to the Google Play app over interprocess communication (IPC) and receives responses from the Google Play app. Your application does not manage any network connections between itself and the Google Play server.

-

In-app Billing can be implemented only in applications that you publish +

You can implement In-app Billing only in applications that you publish through Google Play. To complete in-app purchase requests, the Google Play app must be able to access the Google Play server over the network.

-

In-app billing Version 3 is the latest version, and maintains very broad +

In-app Billing Version 3 is the latest version, and it maintains very broad compatibility across the range of Android devices. In-app Billing Version 3 is -supported on devices running Android 2.2 or higher that have the latest version -of the Google Play store installed (a vast majority of active devices).

Version 3 features

+

In-app Billing Version 3 provides the following features:

For details about other versions of In-app Billing, see the Version Notes.

In-app Products

-

In-app products are the digital goods that you offer for sale from inside your -application to users. Examples of digital goods includes in-game currency, +

In-app products are the digital products that you offer for sale to users from inside your +application. Examples of digital products include in-game currency, application feature upgrades that enhance the user experience, and new content for your application.

You can use In-app Billing to sell only digital content. -You cannot use In-app Billing to sell physical goods, personal services, or -anything that requires physical delivery. Unlike with priced applications, once -the user has purchased an in-app product there is no refund window.

+You can't use In-app Billing to sell physical products, personal services, or +anything that requires physical delivery. Unlike with priced applications, there is no refund + window after +the user has purchased an in-app product.

Google Play does not provide any form of content delivery. You are responsible for delivering the digital content that you sell in your -applications. In-app products are always explicitly associated with one and -only one app. That is, one application cannot purchase an in-app product -published for another app, even if they are from the same developer.

+applications. In-app products are always explicitly associated with + only one app. That is, one application can't purchase an in-app product +that is published for another app, even if they are from the same developer.

Product types

In-app Billing supports different product types to give you flexibility in how you monetize your application. In all cases, you define your products using the Google Play Developer Console.

-

You can specify these types of products for your In-app Billing application -— managed in-app products and subscriptions. Google Play -handles and tracks ownership for in-app products and subscriptions on your -application on a per user account basis. -Learn more about -the product types supported by In-app Billing Version 3.

+

You can specify two product types for your In-app Billing application: + managed in-app products and subscriptions. Google Play +handles and tracks ownership for in-app products and subscriptions for your +application on a per-user basis. +Learn more about +the product types supported by In-app Billing Version 3.

Google Play Developer Console

The Developer Console is where you can publish your In-app Billing application and manage the various in-app products that are available for purchase from your application.

You can create a product list of -digital goods that are associated with your application, including items for -one-time purchase and recurring subscriptions. For each item, you can define -information such as the item’s unique product ID (also called its SKU), product -type, pricing, description, and how Google Play should handle and track -purchases for that product.

+digital products that are associated with your application, including products for +one-time purchase and recurring subscriptions. You can define +information for each product such as the following:

+

If you sell several of your apps or in-app products at the same price, you can add pricing templates to manage these price points from a centralized location. When using pricing templates, you can include local taxes @@ -146,7 +157,7 @@ products and product list, see In-app Billing.

Google Play Purchase Flow

-

Google Play uses the same checkout backend service as is used for application +

Google Play uses the same backend checkout service that is used for application purchases, so your users experience a consistent and familiar purchase flow.

Important: You must have a Google payments merchant account to use the In-app Billing service on Google Play.

@@ -157,8 +168,8 @@ processing the financial transaction.

When the checkout process is complete, Google Play sends your application the purchase details, such as the order number, the order date and time, and the price paid. At no point does your -application have to handle any financial transactions; that role is provided by -Google Play.

+application have to handle any financial transactions; that role belongs to + Google Play.

Sample Application

To help you integrate In-app Billing into your application, the Android SDK @@ -166,16 +177,16 @@ provides a sample application that demonstrates how to sell in-app products and from inside an app.

The -TrivialDrive sample for the Version 3 API sample shows how to use the In-app +TrivialDrive for the Version 3 API sample shows how to use the In-app Billing Version 3 API to implement in-app product and subscription purchases for a driving game. The -application demonstrates how to send In-app Billing requests, and handle +application demonstrates how to send In-app Billing requests and handle synchronous responses from Google Play. The application also shows how to record -item consumption with the API. The Version 3 sample includes convenience classes +product consumption with the API. The Version 3 sample includes convenience classes for processing In-app Billing operations as well as perform automatic signature verification.

-

Recommendation: Make sure to obfuscate the +

Recommendation: Be sure to obfuscate the code in your application before you publish it. For more information, see Security and Design.

@@ -183,16 +194,17 @@ and Design.

Migration Considerations

The In-app Billing Version 2 API was discontinued in January 2015. If you have an existing In-app Billing implementation that uses API Version 2 or -earlier, you must migrate to In-app Billing Version -3.

+earlier, you must migrate to +In-app Billing Version 3.

-

If you have published apps selling in-app products, note that:

+

After migration, managed and unmanaged products are handled as follows:

diff --git a/docs/html/google/play/billing/billing_promotions.jd b/docs/html/google/play/billing/billing_promotions.jd index ccf50fc601c30..4fe1abfc4aa3b 100644 --- a/docs/html/google/play/billing/billing_promotions.jd +++ b/docs/html/google/play/billing/billing_promotions.jd @@ -1,7 +1,7 @@ page.title=In-app Promotions parent.title=In-app Billing parent.link=index.html -page.metaDescription=Support promo codes in your app, which let you give content or features away to a limited number of users free of charge. +page.metaDescription=Support promo codes in your app, which lets you give content or features away to a limited number of users free of charge. page.image=/images/play_dev.jpg page.tags="promotions, billing, promo codes" meta.tags="monetization, inappbilling, promotions" @@ -13,7 +13,7 @@ meta.tags="monetization, inappbilling, promotions"

In this document

  1. Creating and Redeeming Promo Codes
  2. -
  3. Supporting Promo Codes In Your App
  4. +
  5. Supporting Promo Codes in Your App
  6. Testing In-app Promotions

See also

@@ -27,26 +27,26 @@ meta.tags="monetization, inappbilling, promotions"

Promo codes let you give content or features away to a limited number of - users free of charge. Once you create a promo code, you can distribute it + users free of charge. After you create a promo code, you can distribute it subject to the terms of - service. The user enters the promo code in your app or in the Play Store app, - and gets the item at no cost. You can use promo codes in many ways to - creatively engage with users. For example: + service. The user enters the promo code in your app or in the Google Play Store app + and receives the item at no cost. You can use promo codes in many ways to + creatively engage with users, such as the following:

@@ -54,11 +54,11 @@ meta.tags="monetization, inappbilling, promotions"

Every promo code is associated with a particular product ID (also known as a SKU). You can create promo codes for your existing in-app - products. You can also keep a SKU off the Play Store, so the only way to get + products. You can also keep an SKU off the Play Store, so that the only way to get that item is by entering that SKU's promo code. When a user enters the promo - code in the Play Store or in their app, the user gets the item, just as if + code in the Play Store or in an app, the user gets the item, just as if they paid full price for it. If your app already uses In-app Billing version 3 to + "{@docRoot}google/play/billing/api.html">In-app Billing Version 3 to support in-app purchases, it's easy to add support for promo codes.

@@ -67,12 +67,12 @@ meta.tags="monetization, inappbilling, promotions"

You create promo codes through the Google Play - Developer Console. Each promo code is associated with a single product item + Developer Console. Each promo code is associated with a single product registered in the developer console.

- When a user gets a promo code, they redeem it in one of two ways: + A user can redeem a promo code in one of these two ways:

-

- If the promo code is for a consumable product, - the user can apply an additional code for the same product after the first - product is consumed. For example, a game might offer promo codes for a bundle - of extra lives. Betty has two different promo codes for that bundle. She - redeems a single promo code, then launches the game. When the game launches, - the her character receives the lives, consuming the item. She can now redeem - the second promo code for another bundle of lives. (She cannot redeem the - second promo code until after she consumes the item she purchased with the - first promo code.) -

- -

Supporting Promo Codes In Your App

+

Supporting Promo Codes in Your App

- To support promotion codes, your app should call the getPurchases() method whenever the app starts or resumes. This method returns a bundle of all current, unconsumed purchases, including purchases the user made by redeeming - a promo code. This simplest approach is to call getPurchases() in your activity's {@link android.app.Activity#onResume onResume()} method, @@ -119,21 +106,21 @@ meta.tags="monetization, inappbilling, promotions" activity is unpaused. Calling getPurchases() - on startup and resume guarantees that your app will find out about all + on startup and resume guarantees that your app finds out about all purchases and redemptions the user may have made while the app wasn't running. Furthermore, if a user makes a purchase while the app is running and - your app misses it for any reason, your app will still find out about the + your app misses it for any reason, your app still finds out about the purchase the next time the activity resumes and calls getPurchases().

- In addition, your app should allow users to redeem promo codes inside the app + Your app should allow users to redeem promo codes inside the app itself. If your app supports the in-app purchase workflow (described in Making - In-app Billing Requests), your app automatically supports in-app + In-app Billing requests), your app automatically supports in-app redemption of promo codes. When you launch the in-app purchase UI, the user has the option to pay for the purchase with a promo code. Your activity's {@link android.app.Activity#onActivityResult @@ -141,9 +128,9 @@ meta.tags="monetization, inappbilling, promotions" purchase was completed. However, your app should still call getPurchases() - on startup and resume, just in case the purchase and consumption workflow - didn't complete. For example, if the user successfully redeems a promo code, - and then your app crashes before the item is consumed, your app still gets + on startup and resume, in case the purchase and consumption workflow + didn't complete. For example, if the user successfully redeems a promo code + and then your app crashes before the item is consumed, your app still receives information about the purchase when the app calls getPurchases() on its next startup. @@ -160,8 +147,8 @@ meta.tags="monetization, inappbilling, promotions"

To listen for the PURCHASES_UPDATED intent, dynamically create a {@link android.content.BroadcastReceiver} object and register it to listen - for "com.android.vending.billing.PURCHASES_UPDATED". Register - the receiver by putting code like this in your activity's {@link + for com.android.vending.billing.PURCHASES_UPDATED. Register + the receiver by inserting code similar to the following in your activity's {@link android.app.Activity#onResume onResume()} method:

@@ -172,36 +159,34 @@ registerReceiver(myPromoReceiver, promoFilter);

When the user makes a purchase, the system invokes your broadcast receiver's {@link android.content.BroadcastReceiver#onReceive onReceive()} method. That - method should call getPurchases() to see what purchases the user has made.

-

- Your activity's {@link android.app.Activity#onPause onPause()} method should - unregister the broadcast receiver, to reduce system overhead when your app - isn't running: +

To reduce system overhead when your app + isn't running, your activity's {@link android.app.Activity#onPause onPause()} method must + unregister the broadcast receiver:

unRegisterReceiver(myPromoReceiver);

- Note: You should not register this broadcast receiver in the + Note: Don't register this broadcast receiver in the app manifest. Declaring the receiver in the manifest can cause the system to launch the app to handle the intent if the user makes a purchase while the app - isn't running. This behavior is not necessary, and may be annoying to the - user. Instead, your app should call getPurchases() - when the user launches it, to find out about any purchases the user made - while the app wasn't running. + isn't running. This behavior is not necessary and may be annoying to the + user. + To find out about any purchases the user made while the app wasn't running, + call getPurchases() when the user launches the app.

Testing In-app Promotions

- If your app supports in-app promotions, you should test the following use + If your app supports in-app promotions, test the following use cases.

@@ -211,18 +196,18 @@ registerReceiver(myPromoReceiver, promoFilter); If the user redeems a promo code within the app's purchase flow, as described in Making - In-app Billing Requests, the system invokes your activity's {@link + In-app Billing requests, the system invokes your activity's {@link android.app.Activity#onActivityResult onActivityResult()} method to handle the purchase. Verify that {@link android.app.Activity#onActivityResult - onActivityResult()} handles the purchase properly, whether the user uses cash + onActivityResult()} handles the purchase properly, whether the user pays with money or a promo code.

-

User redeems promo code in the Play Store

+

User redeems promo code in the Google Play Store

If the user redeems a promo code in the Play Store, there are several - possible workflows. You should verify each one of these. + possible workflows. Verify each one of these workflows.

App is not installed

@@ -231,16 +216,16 @@ registerReceiver(myPromoReceiver, promoFilter); If the user redeems a promo code for an app that is not installed on the device, the Play Store prompts the user to install the app. (If the app is installed but not up-to-date, the Play Store prompts the user to update the - app.) You should test the following sequence on a device that does not + app.) Test the following sequence on a device that doesn't have your app installed.

    -
  1. User redeems a promo code for the app in the Play Store. The Play Store +
  2. The user redeems a promo code for the app in the Play Store. The Play Store prompts the user to install your app.
  3. -
  4. User installs and launches your app. Verify that on startup, the app +
  5. The user installs and launches your app. Verify that on startup, the app calls getPurchases() @@ -252,16 +237,16 @@ registerReceiver(myPromoReceiver, promoFilter);

    If the user redeems a promo code for an app that is installed on the device, - the Play Store prompts the user to switch to the app. You should test the + the Play Store prompts the user to switch to the app. Test the following sequence on a device that has your app installed but not running:

      -
    1. User redeems a promo code for the app in the Play Store. The Play Store +
    2. The user redeems a promo code for the app in the Play Store. The Play Store prompts the user to switch to your app.
    3. -
    4. User launches your app. Verify that on startup, the app calls The user launches your app. Verify that on startup the app calls getPurchases() and correctly detects the purchase the user made with the promo code. @@ -274,15 +259,15 @@ registerReceiver(myPromoReceiver, promoFilter);

      If the user redeems a promo code for an app that is currently running on the device, the Play Store notifies the app via a PURCHASES_UPDATED - intent. You should test the following sequence: + intent. Test the following sequence:

        -
      1. User launches the app. Verify that the app has properly registered itself to +
      2. The user launches the app. Verify that the app has properly registered itself to receive the PURCHASES_UPDATED intent.
      3. -
      4. User launches the Play Store app and redeems a promo code for the app. The Play +
      5. The user launches the Play Store app and redeems a promo code for the app. The Play Store fires a PURCHASES_UPDATED intent. Verify that your app's {@link android.content.BroadcastReceiver#onReceive BroadcastReceiver.onReceive()} callback fires to handle the intent. @@ -291,11 +276,11 @@ registerReceiver(myPromoReceiver, promoFilter);
      6. Your {@link android.content.BroadcastReceiver#onReceive onReceive()} method should respond to the intent by calling getPurchases(). Verify that it calls this method, and that + >getPurchases(). Verify that your app calls this method and that it correctly detects the purchase the user made with the promo code.
      7. -
      8. User switches back to your app. Verify that the user has the purchased +
      9. The user switches back to your app. Verify that the user has the purchased item.
      diff --git a/docs/html/training/in-app-billing/preparing-iab-app.jd b/docs/html/training/in-app-billing/preparing-iab-app.jd old mode 100755 new mode 100644 index 2c6e9a074d317..780f2f800a7c9 --- a/docs/html/training/in-app-billing/preparing-iab-app.jd +++ b/docs/html/training/in-app-billing/preparing-iab-app.jd @@ -31,23 +31,32 @@ next.link=list-iab-products.html +href="https://www.youtube.com/watch?v=UvCl5Xx7Z5o" class="external-link">

      Video

      Implementing Freemium

      -

      Before you can start using the In-app Billing service, you'll need to add the library that contains the In-app Billing Version 3 API to your Android project. You also need to set the permissions for your application to communicate with Google Play. In addition, you'll need to establish a connection between your application and Google Play. You should also verify that the In-app Billing API version that you are using in your application is supported by Google Play.

      +

      Before you can start using the In-app Billing service, you need to add the library that + contains the In-app Billing Version 3 API to your Android project. You also need to set the + permissions for your application to communicate with Google Play. In addition, you need to + establish a connection between your application and Google Play. You must also verify that + the In-app Billing API version that you are using in your application is supported + by Google Play.

      Download the Sample Application

      -

      In this training class, you will use a reference implementation for the In-app Billing Version 3 API called the {@code TrivialDrive} sample application. The sample includes convenience classes to quickly set up the In-app Billing service, marshal and unmarshal data types, and handle In-app Billing requests from the main thread of your application.

      -

      To download the sample application:

      +

      In this training class, you use a reference implementation for the In-app Billing + Version 3 API + called the {@code TrivialDrive} sample application. The sample includes convenience classes to + quickly set up the In-app Billing service, marshal and unmarshal data types, and handle In-app + Billing requests from the main thread of your application.

      +

      To download the sample application, follow these steps:

      1. Open Android Studio and then close any open projects until you are presented with the welcome screen.
      2. -
      3. Choose Import an Android code sample from the - Quick Start list on the right side the window.
      4. +
      5. From the Quick Start list on the right side of the window, choose + Import an Android code sample.
      6. Type {@code Trivial Drive} into the search bar and select the Trivial Drive sample.
      7. Follow the rest of the instructions in the Import Sample @@ -56,66 +65,121 @@ presented with the welcome screen.

      Alternatively, you can use {@code git} to manually clone - the repository from https://github.com/googlesamples/android-play-billing

      + class="external-link">Google Samples GitHub site.

      Add Your Application to the Developer Console

      -

      The Google Play Developer Console is where you publish your In-app Billing application and manage the various digital goods that are available for purchase from your application. When you create a new application entry in the Developer Console, it automatically generates a public license key for your application. You will need this key to establish a trusted connection from your application to the Google Play servers. You only need to generate this key once per application, and don’t need to repeat these steps when you update the APK file for your application.

      -

      To add your application to the Developer Console:

      +

      The Google Play Developer Console is where you publish your In-app Billing application + and manage the various digital products that are available for purchase from your + application. + When you create a new application entry in the Developer Console, it automatically generates + a public license key for your application. You need this key to establish a trusted connection + from your application to the Google Play servers. You need to generate this key only once + per application, and you don’t need to repeat these steps when you update the APK file for + your application.

      +

      To add your application to the Developer Console, follow these steps:

        -
      1. Go to the Google Play Developer Console site and log in. You will need to register for a new developer account, if you have not registered previously. To sell in-app items, you also need to have a Google payments merchant account.
      2. -
      3. Click on Try the new design to access the preview version of the Developer Console, if you are not already logged on to that version.
      4. -
      5. In the All Applications tab, add a new application entry. +
      6. Go to the +Google Play Developer Console + site and log in. If you have not registered previously, you need to register for a new + developer account. To sell in-app products, you also need a + + Google payments merchant account.
      7. + +
      8. In the All Applications tab, complete these steps to add a new + application entry:
        1. Click Add new application.
        2. Enter a name for your new In-app Billing application.
        3. Click Prepare Store Listing.
      9. -
      10. In the Services & APIs tab, find and make a note of the public license key that Google Play generated for your application. This is a Base64 string that you will need to include in your application code later.
      11. +
      12. In the Services & APIs tab, find and make a note of the public license key + that Google Play generated for your application. This is a Base64 string that you need to + include in your application code later.

      Your application should now appear in the list of applications in Developer Console.

      Add the In-app Billing Library

      -

      To use the In-app Billing Version 3 features, you must add the {@code IInAppBillingService.aidl} file to your Android project. This Android Interface Definition Language (AIDL) file defines the interface to the Google Play service.

      -

      You can find the {@code IInAppBillingService.aidl} file in the provided sample app. Depending on whether you are creating a new application or modifying an existing application, follow the instructions below to add the In-app Billing Library to your project.

      -

      New Project

      -

      To add the In-app Billing Version 3 library to your new In-app Billing project:

      +

      To use the In-app Billing Version 3 features, you must add the + {@code IInAppBillingService.aidl} + file to your Android project. This Android Interface Definition Language + (AIDL) file defines the + interface to the Google Play service.

      +

      You can find the {@code IInAppBillingService.aidl} file in the provided sample app. + To add the + In-app Billing library to your project, follow the instructions below for a new or + existing project.

      +

      Adding in-app billing to a new project

      +

      To add the In-app Billing Version 3 library to a new project, follow these steps:

      1. Copy the {@code TrivialDrive} sample files into your Android project.
      2. -
      3. Modify the package name in the files you copied to use the package name for your project. In Android Studio, you can use this shortcut: right-click the package name, then select Refactor > Rename.
      4. -
      5. Open the {@code AndroidManifest.xml} file and update the package attribute value to use the package name for your project.
      6. -
      7. Fix import statements as needed so that your project compiles correctly. In Android Studio, you can use this shortcut: press Ctrl+Shift+O in each file showing errors.
      8. -
      9. Modify the sample to create your own application. Remember to copy the Base64 public license key for your application from the Developer Console over to your {@code MainActivity.java}.
      10. +
      11. Modify the package name in the files that you copied to use the package name + for your project. + In Android Studio, you can right-click the package name and then + select Refactor > Rename.
      12. +
      13. Open the {@code AndroidManifest.xml} file and update the package attribute value to + use the package name for your project.
      14. +
      15. Fix import statements as needed so that your project compiles correctly. + In Android Studio, you can press Ctrl+Shift+O + in each file showing errors.
      16. +
      17. Modify the sample to create your own application. Remember to copy the Base64 + public license key for your application from the Developer Console to + your {@code MainActivity.java}.
      -

      Existing Project

      -

      To add the In-app Billing Version 3 library to your existing In-app Billing project:

      +

      Adding in-app billing to an existing project

      +

      To add the In-app Billing Version 3 library to an existing project, follow these steps:

      1. Copy the {@code IInAppBillingService.aidl} file to your Android project.
          -
        • In Android Studio: Create a directory named {@code aidl} under {@code src/main}, add a new - package {@code com.android.vending.billing} in this directory, and import the +
        • In Android Studio: Create a directory named {@code aidl} under {@code src/main}, + add a new + package {@code com.android.vending.billing} in this directory, and then import the {@code IInAppBillingService.aidl} file into this package.
        • -
        • In other dev environments: Create the following directory {@code /src/com/android/vending/billing} and copy the {@code IInAppBillingService.aidl} file into this directory.
        • +
        • In other dev environments: Create the following directory + {@code /src/com/android/vending/billing} and copy the {@code IInAppBillingService.aidl} + file into this directory.
      2. -
      3. Build your application. You should see a generated file named {@code IInAppBillingService.java} in the {@code /gen} directory of your project.
      4. -
      5. Add the helper classes from the {@code /util} directory of the {@code TrivialDrive} sample to your project. Remember to change the package name declarations in those files accordingly so that your project compiles correctly.
      6. +
      7. Build your application. You should see a generated file named + {@code IInAppBillingService.java} + in the {@code /gen} directory of your project.
      8. +
      9. Add the helper classes from the {@code /util} directory of the {@code TrivialDrive} + sample to + your project. Remember to change the package name declarations in those files + accordingly so + that your project compiles correctly.

      Your project should now contain the In-app Billing Version 3 library.

      Set the Billing Permission

      -

      Your app needs to have permission to communicate request and response messages to the Google Play’s billing service. To give your app the necessary permission, add this line in your {@code AndroidManifest.xml} manifest file:

      +

      Your app needs to have permission to communicate request and response messages to + the Google Play billing service. To give your app the necessary permission, add the following + line in your {@code AndroidManifest.xml} manifest file:

       <uses-permission android:name="com.android.vending.BILLING" />
       

      Initiate a Connection with Google Play

      -

      You must bind your Activity to Google Play’s In-app Billing service to send In-app Billing requests to Google Play from your application. The convenience classes provided in the sample handles the binding to the In-app Billing service, so you don’t have to manage the network connection directly.

      -

      To set up synchronous communication with Google Play, create an {@code IabHelper} instance in your activity's {@code onCreate} method. In the constructor, pass in the {@code Context} for the activity, along with a string containing the public license key that was generated earlier by the Google Play Developer Console.

      -

      Security Recommendation: It is highly recommended that you do not hard-code the exact public license key string value as provided by Google Play. Instead, you can construct the whole public license key string at runtime from substrings, or retrieve it from an encrypted store, before passing it to the constructor. This approach makes it more difficult for malicious third-parties to modify the public license key string in your APK file.

      +

      To send In-app + Billing requests to Google Play from your application, you must bind your Activity + to the Google Play In-app Billing service. The sample includes convenience classes + that handle the binding to the In-app Billing service, so you don’t have to + manage the network connection directly.

      +

      To set up synchronous communication with Google Play, create an {@code IabHelper} + instance in your activity's {@code onCreate} method, as shown in the following example. + In the constructor, pass in the {@code Context} for the activity along with a string + containing the public license key that was generated earlier by the Google Play + Developer Console. +

      +

      Security Recommendation: Google highly recommends that + you do not hard-code the exact public license key string value as provided by Google Play. + Instead, construct the whole public license key string at runtime from substrings + or retrieve it from an encrypted store before passing it to the constructor. + This approach makes it more difficult for malicious third parties to modify the public + license key string in your APK file.

       IabHelper mHelper;
      @@ -130,13 +194,20 @@ public void onCreate(Bundle savedInstanceState) {
       }
       
      -

      Next, perform the service binding by calling the {@code startSetup} method on the {@code IabHelper} instance that you created. Pass the method an {@code OnIabSetupFinishedListener} instance, which is called once the {@code IabHelper} completes the asynchronous setup operation. As part of the setup process, the {@code IabHelper} also checks if the In-app Billing Version 3 API is supported by Google Play. If the API version is not supported, or if an error occured while establishing the service binding, the listener is notified and passed an {@code IabResult} object with the error message.

      +

      Next, perform the service binding by calling the {@code startSetup} method on the + {@code IabHelper} instance that you created, as shown in the following example. + Pass the method an {@code OnIabSetupFinishedListener} instance, which is called once + the {@code IabHelper} completes the asynchronous setup operation. As part of the + setup process, the {@code IabHelper} also checks if the In-app Billing Version 3 API + is supported by Google Play. If the API version is not supported, or if an error occurs + while establishing the service binding, the listener is notified and passed an + {@code IabResult} object with the error message.

       mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
          public void onIabSetupFinished(IabResult result) {
             if (!result.isSuccess()) {
      -         // Oh noes, there was a problem.
      +         // Oh no, there was a problem.
                Log.d(TAG, "Problem setting up In-app Billing: " + result);
             }
                // Hooray, IAB is fully set up!
      @@ -144,9 +215,18 @@ mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
       });
       
      -

      If the setup completed successfully, you can now use the {@code mHelper} reference to communicate with the Google Play service. When your application is launched, it is a good practice to query Google Play to find out what in-app items are owned by a user. This is covered further in the Query Purchased Items section.

      +

      If the setup completed successfully, you can now use the {@code mHelper} reference + to communicate with the Google Play service. When your application is launched, it is + a good practice to query Google Play to find out what in-app items are owned by a user. + This is covered further in the + + Query Purchased Items section.

      -

      Important: Remember to unbind from the In-app Billing service when you are done with your activity. If you don’t unbind, the open service connection could cause your device’s performance to degrade. To unbind and free your system resources, call the {@code IabHelper}'s {@code dispose} method when your {@code Activity} is destroyed.

      +

      Important: Remember to unbind from the In-app Billing service + when you are done with your activity. If you don’t unbind, the open service connection could + degrade device performance. To unbind and free your system resources, call the + {@code IabHelper}'s {@code dispose} method when your {@code Activity} is destroyed, + as shown in the following example.

       @Override
      @@ -156,8 +236,3 @@ public void onDestroy() {
          mHelper = null;
       }
       
      - - - - -