docs: Improved Google Play Developer Console documentation

The "In-app Promotions," "Preparing Your In-app Billing Application,"
"In-app Billing Overview," and "Developer Console" pages now contain
up-to-date content and use a cleaner writing style.

Bug: 29358568
Change-Id: I0d21fba8ef6bedbacdb38e7a5203041e79cb455f
This commit is contained in:
Kevin Hufnagle
2016-06-30 16:49:15 -07:00
parent a211850784
commit ec8b21a27a
4 changed files with 367 additions and 279 deletions

View File

@@ -10,30 +10,30 @@ Xnonavpage=true
<div id="qv">
<h2>Features</h2>
<ol>
<li><a href="#latest">Latest blog posts</a></li>
<li><a href="#publish">Publish with confidence</a></li>
<li><a href="#aquire-users">Acquire users</a></li>
<li><a href="#insights">Actionable insights</a></li>
<li><a href="#manage">Manage your app</a></li>
<li><a href="#latest">Latest Blog Posts</a></li>
<li><a href="#publish">Publish with Confidence</a></li>
<li><a href="#aquire-users">Acquire Users</a></li>
<li><a href="#insights">Learn about Users and App Performance</a></li>
<li><a href="#manage">Manage Your App</a></li>
</ol>
</div>
</div>
<p>
The <a href="https://play.google.com/apps/publish/">Google Play Developer
Console</a> is your home for publishing operations and tools.
The <a class="external-link" href="https://play.google.com/apps/publish/">Google Play Developer
Console</a> is your home for publishing and managing your apps.
</p>
<img src="{@docRoot}images/distribute/googleplay/gp-devconsole-home.png" style="width:480px;">
<p>
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.
</p>
<p>
Once you've <a href=
After you've <a href=
"{@docRoot}distribute/googleplay/start.html">registered</a> and received
verification by email, you can sign in to your Google Play Developer Console.
</p>
@@ -44,7 +44,7 @@ Xnonavpage=true
<div class="dynamic-grid">
<div class="headerLine">
<h2 id="latest">Latest blog posts</h2>
<h2 id="latest">Latest Blog Posts</h2>
</div>
<div class="resource-widget resource-flow-layout col-13"
@@ -54,31 +54,10 @@ Xnonavpage=true
data-maxResults="3"></div>
</div>
<h2 id="publish">Publish with confidence</h2>
<h2 id="publish">Publish with Confidence</h2>
<p>The Developer Console provides rich testing features and staged rollouts that help you to
provide apps that satisfy your users.</p>
<div class="wrap">
<h3 id="alpha-beta">Alpha and beta tests</h3>
<div class="cols" style="margin-top:2em;">
<div class="col-3of12">
<p>
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 apps public reviews and rating. This valuable feedback
will help you test features and improve the quality of your app.
<a href="{@docRoot}distribute/engage/beta.html">Learn more</a>.
</p>
</div>
<div class="col-8of12 col-push-1of12">
<img src=
"{@docRoot}images/distribute/googleplay/dev-console_running-a-beta-test.png"
srcset=
"{@docRoot}images/distribute/googleplay/dev-console_running-a-beta-test.png 1x, {@docRoot}images/distribute/googleplay/dev-console_running-a-beta-test_2x.png 2x"
width="500">
</div>
</div>
<h3 id="cloud-test">Cloud Test Lab</h3>
@@ -87,8 +66,8 @@ Xnonavpage=true
<p>
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. <a href=
"https://developers.google.com/cloud-test-lab/" class=
@@ -100,57 +79,85 @@ Xnonavpage=true
<img src=
"{@docRoot}images/distribute/googleplay/dev-console_cloud-test-lab.png"
srcset=
"{@docRoot}images/distribute/googleplay/dev-console_cloud-test-lab.png 1x, {@docRoot}images/distribute/googleplay/dev-console_cloud-test-lab_2x.png 2x"
"{@docRoot}images/distribute/googleplay/dev-console_cloud-test-lab.png 1x,
{@docRoot}images/distribute/googleplay/dev-console_cloud-test-lab_2x.png 2x"
width="500">
</div>
</div>
</div>
<h3 id="alpha-beta">Alpha and beta tests</h3>
<div class="cols" style="margin-top:2em;">
<div class="col-3of12">
<p>
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 apps public reviews and rating. This valuable feedback
helps you test features and improve the quality of your app.
<a href="{@docRoot}distribute/engage/beta.html">Learn more</a>.
</p>
</div>
<div class="col-8of12 col-push-1of12">
<img src=
"{@docRoot}images/distribute/googleplay/dev-console_running-a-beta-test.png"
srcset=
"{@docRoot}images/distribute/googleplay/dev-console_running-a-beta-test.png 1x,
{@docRoot}images/distribute/googleplay/dev-console_running-a-beta-test_2x.png 2x"
width="500">
</div>
</div>
<h3 id="staged-rollouts">Staged rollouts</h3>
<p>
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. <a href=
Discover and fix problems with a limited user base before making a wider release.
With staged rollouts, you can release app updates progressively to an increasing portion of
your users.
You can fix problems before your app reaches the broader user community. <a href=
"https://support.google.com/googleplay/android-developer/answer/3131213"
class="external-link">Learn more.</a>
class="external-link">Learn more</a>.
</p>
<p class="aside">
<strong>Tip:</strong> 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.
<p class="note">
<strong>Tip:</strong> If you find an issue during a rollout stage, you can
halt the rollout, make the fix, and then resume.
</p>
<h2 id="aquire-users">Aquire users</h2>
<h3 id="adwords">AdWords Universal App Campaigns</h3>
<h2 id="aquire-users">Acquire Users</h2>
<p>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.</p>
<h3 id="adwords">Promote your app with AdWords</h3>
<p>
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. <a href="{@docRoot}distribute/users/promote-with-ads.html">Learn
more</a>.
</p>
<div class="wrap">
<h3 id="listing-experiments">Store Listing Experiments</h3>
<h3 id="listing-experiments">Increase installs with improved store listings</h3>
<div class="cols" style="margin-top:2em;">
<div class="col-3of12">
<p>
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
<p>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. <a href="{@docRoot}distribute/users/experiments.html">Learn
more</a>.
</p>
<p class="aside">
<strong>Tip:</strong> You can even try out different orders for your
screenshots and other images to discover which grabs users attention
the best.
<p class="note">
<strong>Tip:</strong> You can reorder your screenshots and other images in different ways
to determine the arrangement that best attracts users.
</p>
</div>
@@ -158,20 +165,21 @@ Xnonavpage=true
<img src=
"{@docRoot}images/distribute/googleplay/dev-console_store-listing-experiment.png"
srcset=
"{@docRoot}images/distribute/googleplay/dev-console_store-listing-experiment.png 1x, {@docRoot}images/distribute/googleplay/dev-console_store-listing-experiment_2x.png 2x"
"{@docRoot}images/distribute/googleplay/dev-console_store-listing-experiment.png 1x,
{@docRoot}images/distribute/googleplay/dev-console_store-listing-experiment_2x.png 2x"
width="500">
</div>
</div>
<h3 id="user-perf-report">User Acquisition performance report</h3>
<h3 id="user-perf-report">User acquisition performance report</h3>
<div class="cols" style="margin-top:2em;">
<div class="col-3of12">
<p>
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. <a href=
Discover information about visitors to your Play Store listing, such as where they come
from, how many go on to install your app, and how many buy your in-app products. You
can also compare cohorts, examine acquisition channels, and see details of users and
buyers. <a href=
"{@docRoot}distribute/users/user-acquisition.html">Learn more</a>.
</p>
</div>
@@ -180,14 +188,16 @@ Xnonavpage=true
<img src=
"{@docRoot}images/distribute/googleplay/dev-console_conversion-funnel.png"
srcset=
"{@docRoot}images/distribute/googleplay/dev-console_conversion-funnel.png 1x, {@docRoot}images/distribute/googleplay/dev-console_conversion-funnel_2x.png 2x"
"{@docRoot}images/distribute/googleplay/dev-console_conversion-funnel.png 1x,
{@docRoot}images/distribute/googleplay/dev-console_conversion-funnel_2x.png 2x"
width="500">
</div>
</div>
</div>
<h2 id="insights">Actionable insights</h2>
<h2 id="insights">Learn about App Users and Performance</h2>
<p>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. </p>
<div class="wrap">
<h3 id="player-analytics">Player Analytics</h3>
@@ -195,8 +205,10 @@ Xnonavpage=true
<div class="cols" style="margin-top:2em;">
<div class="col-3of12">
<p>
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. <a href=
"{@docRoot}distribute/engage/game-services.html">Learn more</a>.
</p>
@@ -206,7 +218,8 @@ Xnonavpage=true
<img src=
"{@docRoot}images/distribute/googleplay/dev-console_player-analytics.png"
srcset=
"{@docRoot}images/distribute/googleplay/dev-console_player-analytics.png 1x, {@docRoot}images/distribute/googleplay/dev-console_player-analytics_2x.png 2x"
"{@docRoot}images/distribute/googleplay/dev-console_player-analytics.png 1x,
{@docRoot}images/distribute/googleplay/dev-console_player-analytics_2x.png 2x"
width="500">
</div>
</div>
@@ -216,74 +229,77 @@ Xnonavpage=true
<div class="cols" style="margin-top:2em;">
<div class="col-3of12">
<p>
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. <a href=
"https://support.google.com/googleplay/android-developer/topic/3450942?ref_topic=3450986"
class="external-link">Learn more.</a>
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. <a href=
"https://support.google.com/googleplay/android-developer/topic/3450942?ref_topic=3450986"
class="external-link">Learn more</a>.
</p>
</div>
<div class="col-8of12 col-push-1of12">
<img src=
"{@docRoot}images/distribute/googleplay/dev-console_statistics.png" srcset=
"{@docRoot}images/distribute/googleplay/dev-console_statistics.png 1x, {@docRoot}images/distribute/googleplay/dev-console_statistics_2x.png 2x"
"{@docRoot}images/distribute/googleplay/dev-console_statistics.png 1x,
{@docRoot}images/distribute/googleplay/dev-console_statistics_2x.png 2x"
width="500">
</div>
</div>
</div>
<h3 id="optimization"> Optimization tips</h3>
<h3 id="optimization">Optimization tips</h3>
<p>
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&mdash;everything
from updating old APIs to suggested languages for localization.
</p>
<h2 id="manage">Manage your app</h2>
<h2 id="manage">Manage Your App</h2>
<h3 id="manage-apks">Manage your APKs</h3>
<p>
Upload and manage your Android application packages (APK) to the Developer
Console as drafts or to your Alpha, Beta, or Production channels. <a href=
Console as drafts or to your Alpha, Beta, or Production channels. <a href=
"https://support.google.com/googleplay/android-developer/answer/113469?ref_topic=3450986"
class="external-link">Learn more.</a>
class="external-link">Learn more</a>.
</p>
<p class="aside">
<strong>Tip:</strong> Ensure users get the best possible experience for the
<p class="note">
<strong>Tip:</strong> 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 <a href="https://developer.android.com/training/multiple-apks/index.html">
Maintaining Multiple APKs.</a>
</p>
<h3 id="iap">In-app products and subscriptions</h3>
<p>
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. <a href=
Manage your in-app products and price them for local markets.
Offer weekly, monthly, annual, or seasonal subscriptions. Attract new users
with features such as grace periods and trials. <a href=
"https://support.google.com/googleplay/android-developer/topic/3452896?ref_topic=3452890"
class="external-link">Learn more.</a>
class="external-link">Learn more</a>.
</p>
<h3 id="pricing">Pricing and distribution</h3>
<p>
Control the price of your app for each country you choose to distribute to.
Make your app available to new audiencesopt-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&mdash;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. <a href=
"https://support.google.com/googleplay/android-developer/answer/113469#pricing"
class="external-link">Learn more</a>.
</p>
<p class="external-link">
<strong>Tip:</strong> You can set prices in other countries automatically
based on current exchange rates using the <strong>auto-convert prices
now</strong> feature.
<p class="note">
<strong>Note:</strong> 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 <strong>Refresh exchange rates</strong>.
</p>
<p style="clear:both">

View File

@@ -7,19 +7,20 @@ parent.link=index.html
<div id="qv">
<h2>Quickview</h2>
<ul>
<li>Use In-app Billing to sell digital goods, including one-time items and
<li>Use In-app Billing to sell digital products, including one-time products and
recurring subscriptions.</li>
<li>Supported for any app published on Google Play. You only need a Google
<li>In-app Billing is supported for any app published on Google Play. You need only a
Google
Play Developer Console account and a Google payments merchant account.</li>
<li>Checkout processing is automatically handled by Google Play, with the
same look-and-feel as for app purchases.</li>
<li>Google Play automatically handles checkout processing with the
same look and feel as app purchases.</li>
</ul>
<h2>In this document</h2>
<ol>
<li><a href="#api">In-app Billing API</a></li>
<li><a href="#products">In-app Products</a>
<ol>
<li><a href="#prodtypes">Product Types</a>
<li><a href="#prodtypes">Product types</a>
</ol>
</li>
<li><a href="#console">Google Play Developer Console</a></li>
@@ -27,30 +28,33 @@ same look-and-feel as for app purchases.</li>
<li><a href="#samples">Sample App</a></li>
<li><a href="#migration">Migration Considerations</a></li>
</ol>
<h2>Related Samples</h2>
<h2>Related samples</h2>
<ol>
<li><a href="{@docRoot}training/in-app-billing/preparing-iab-app.html#GetSample">Sample
Application (V3)</a></li>
</ol>
<h2>Related Videos</h2>
<h2>Related videos</h2>
<ol>
<li><a href="https://www.youtube.com/watch?v=UvCl5Xx7Z5o">Implementing
<li><a class="external-link" href="https://www.youtube.com/watch?v=UvCl5Xx7Z5o">
Implementing
Freemium</a></li>
</ol>
</div>
</div>
<p>This documentation describes the fundamental In-app Billing components and
<p>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.</p>
<p class="note"><b>Note</b>: Ensure that you comply with applicable laws in the countries where you
distribute apps. For example, in EU countries, laws based on the
<a href="http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=OJ:L:2005:149:0022:0039:EN:PDF">
Unfair Commercial Practices Directive</a> 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
<a href="http://ec.europa.eu/consumers/enforcement/docs/common_position_on_online_games_en.pdf">
<p class="note"><b>Note</b>: Ensure that you comply with applicable laws in the countries where
you distribute apps. For example, in EU countries, laws based on the
<a class="external-link"
href="http://eur-lex.europa.eu/LexUriServ/LexUriServ.do?uri=OJ:L:2005:149:0022:0039:EN:PDF">
Unfair Commercial Practices Directive</a> 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
<a class="external-link"
href="http://ec.europa.eu/consumers/enforcement/docs/common_position_on_online_games_en.pdf">
position of the EU consumer protection authorities</a> for more information on this and other
topics.
</p>
@@ -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.</p>
<p>In-app Billing can be implemented only in applications that you publish
<p>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.</p>
<p>In-app billing Version 3 is the latest version, and maintains very broad
<p>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
supported on devices running Android 2.2 (API level 8) or higher that have the latest version
of the Google Play app installed (<a
href="{@docRoot}about/dashboards/index.html">a vast majority</a> of active
devices).</p>
<h4>Version 3 features</h4>
<p>In-app Billing Version 3 provides the following features:</p>
<ul>
<li>Requests are sent through a streamlined API that allows you to easily request
product details from Google Play, order in-app products, and quickly restore
items based on users' product ownership</li>
<li>Order information is synchronously propagated to the device on purchase
completion</li>
<li>All purchases are managed (that is, Google Play keeps track of the user's
ownership of in-app products). The user cannot own multiple copies of an in-app
item; only one copy can be owned at any point in time</li>
<li>Purchased items can be consumed. When consumed, the item reverts to the
"unowned" state and can be purchased again from Google Play</li>
<li>Provides support for <a
href="{@docRoot}google/play/billing/billing_subscriptions.html">subscriptions</a></li>
<li>Your app sends requests through a streamlined API that allows users to easily request
product details from Google Play and order in-app products. The API quickly restores
products based on the user's ownership.</li>
<li>The API synchronously propagates order information to the device on purchase
completion.</li>
<li>All purchases are <em>managed</em> (that is, Google Play keeps track of the user's
ownership of in-app products). The user can't own multiple copies of an in-app
product; only one copy can be owned at any point in time.</li>
<li>Purchased products can be consumed. When consumed, the product reverts to the
<em>unowned</em> state and can be purchased again from Google Play.</li>
<li>The API provides support for <a
href="{@docRoot}google/play/billing/billing_subscriptions.html">subscriptions</a>.</li>
</ul>
<p>For details about other versions of In-app Billing, see the
<a href="{@docRoot}google/play/billing/versions.html">Version Notes</a>.</p>
<h2 id="products">In-app Products</h2>
<p>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,
<p>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.</p>
<p>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.</p>
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.</p>
<p>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.</p>
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.</p>
<h3 id="prodtypes">Product types</h3>
<p>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.</p>
<p>You can specify these types of products for your In-app Billing application
<em>managed in-app products</em> and <em>subscriptions</em>. Google Play
handles and tracks ownership for in-app products and subscriptions on your
application on a per user account basis.
<a href="{@docRoot}google/play/billing/api.html#producttypes">Learn more about
the product types supported by In-app Billing Version 3</a>.</p>
<p>You can specify two product types for your In-app Billing application:
<em>managed in-app products</em> and <em>subscriptions</em>. Google Play
handles and tracks ownership for in-app products and subscriptions for your
application on a per-user basis.
<a href="{@docRoot}google/play/billing/api.html#producttypes">Learn more</a> about
the product types supported by In-app Billing Version 3.</p>
<h2 id="console">Google Play Developer Console</h2>
<p>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.</p>
<p>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 items unique product ID (also called its SKU), product
type, pricing, description, and how Google Play should handle and track
purchases for that product.</p>
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:</p>
<ul>
<li>Unique product ID (also called its SKU).</li>
<li>Product type.</li>
<li>Pricing.</li>
<li>Description.</li>
<li>Google Play handling and tracking of purchases for that product.</li></p>
</ul>
<p>If you sell several of your apps or in-app products at the same price, you
can add <em>pricing templates</em> 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</a>.</p>
<h2 id="checkout">Google Play Purchase Flow</h2>
<p>Google Play uses the same checkout backend service as is used for application
<p>Google Play uses the same backend checkout service that is used for application
purchases, so your users experience a consistent and familiar purchase flow.</p>
<p class="note"><strong>Important:</strong> You must have a Google payments
merchant account to use the In-app Billing service on Google Play.</p>
@@ -157,8 +168,8 @@ processing the financial transaction.</p>
<p>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.</p>
application have to handle any financial transactions; that role belongs to
Google Play.</p>
<h2 id="samples">Sample Application</h2>
<p>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.</p>
<p>The <a href="{@docRoot}training/in-app-billing/preparing-iab-app.html#GetSample">
TrivialDrive sample for the Version 3 API</a> sample shows how to use the In-app
TrivialDrive for the Version 3 API</a> 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.</p>
<p class="caution"><strong>Recommendation</strong>: Make sure to obfuscate the
<p class="caution"><strong>Recommendation</strong>: Be sure to obfuscate the
code in your application before you publish it. For more information, see
<a href="{@docRoot}google/play/billing/billing_best_practices.html">Security
and Design</a>.</p>
@@ -183,16 +194,17 @@ and Design</a>.</p>
<h2 id="migration">Migration Considerations</h2>
<p>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 <a href="{@docRoot}google/play/billing/api.html">In-app Billing Version
3</a>.</p>
earlier, you must migrate to <a href="{@docRoot}google/play/billing/api.html">
In-app Billing Version 3</a>.</p>
<p>If you have published apps selling in-app products, note that:</p>
<p>After migration, managed and unmanaged products are handled as follows:</p>
<ul>
<li>Managed items and subscriptions that you have previously defined in the Developer Console will
work with Version 3 as before.</li>
<li>Unmanaged items that you have defined for existing applications will be
treated as managed products if you make a purchase request for these items using
the Version 3 API. You do not need to create a new product entry in Developer
Console for these items, and you can use the same product IDs to purchase these
items.
<li>Managed products and subscriptions that you have previously defined in the
Developer Console
work with Version 3 just as before.</li>
<li>Unmanaged products that you have defined for existing applications are
treated as managed products if you make a purchase request for these products using
the Version 3 API. You don't need to create a new product entry in the Developer
Console for these products, and you can use the same product IDs to manage these
products.
</ul>

View File

@@ -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"
<h2>In this document</h2>
<ol>
<li><a href="#workflow">Creating and Redeeming Promo Codes</a></li>
<li><a href="#supporting">Supporting Promo Codes In Your App</a></li>
<li><a href="#supporting">Supporting Promo Codes in Your App</a></li>
<li><a href="#testing">Testing In-app Promotions</a></li>
</ol>
<h2>See also</h2>
@@ -27,26 +27,26 @@ meta.tags="monetization, inappbilling, promotions"
<p>
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
<!--TODO: Link to TOS when/if they're available as a web page --> 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:
</p>
<ul>
<li>A game could have a special item, such as a character or decoration,
that's only available to players who attend an event. The developer could
distribute cards with promo codes at the event, and users would enter their
promo code to unlock the item.
promo codes to unlock the item.
</li>
<li>An app developer might distribute promo codes at local businesses, to
<li>An app developer might distribute promo codes at local businesses to
encourage potential users to try the app.
</li>
<li>An app developer might give out "friends and family" codes to its employees to
<li>An app developer might give <em>friends and family codes</em> to its employees to
share with their friends.
</li>
</ul>
@@ -54,11 +54,11 @@ meta.tags="monetization, inappbilling, promotions"
<p>
Every promo code is associated with a particular <em>product ID</em> (also
known as a <em>SKU</em>). 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 <a href=
"{@docRoot}google/play/billing/api.html">In-app Billing version 3</a> to
"{@docRoot}google/play/billing/api.html">In-app Billing Version 3</a> to
support in-app purchases, it's easy to add support for promo codes.
</p>
@@ -67,12 +67,12 @@ meta.tags="monetization, inappbilling, promotions"
<p>
You create promo codes through the <a href=
"https://play.google.com/apps/publish/" class="external-link">Google Play
Developer Console</a>. Each promo code is associated with a single product item
Developer Console</a>. Each promo code is associated with a single product
registered in the developer console.
</p>
<p>
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:
</p>
<ul>
@@ -85,33 +85,20 @@ meta.tags="monetization, inappbilling, promotions"
<li>The user can redeem the code in the Google Play Store app. Once the user
enters the code, the Play Store prompts the user to open the app (if they have
the latest version installed) or to download or update it. (We do not
currently support redeeming promo codes from the Google Play web store.)
the latest version installed) or to download or update it. Google doesn't
currently support redeeming promo codes from the Google Play web store.
</li>
</ul>
<p>
If the promo code is for a <a href=
"{@docRoot}google/play/billing/api.html#consumetypes">consumable product</a>,
the user can apply an additional code for the same product <em>after</em> 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.)
</p>
<h2 id="supporting">Supporting Promo Codes In Your App</h2>
<h2 id="supporting">Supporting Promo Codes in Your App</h2>
<p>
To support promotion codes, your app should call the <a href=
To support promotion codes, your app must call the <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a>
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 <a href=
a promo code. The simplest approach is to call <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a>
in your activity's {@link android.app.Activity#onResume onResume()} method,
@@ -119,21 +106,21 @@ meta.tags="monetization, inappbilling, promotions"
activity is unpaused. Calling <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a>
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 <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a>.
</p>
<p>
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
<a href=
"{@docRoot}google/play/billing/billing_integrate.html#billing-requests">Making
In-app Billing Requests</a>), your app automatically supports in-app
In-app Billing requests</a>), 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 <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a>
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 <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a> on its next startup.
@@ -160,8 +147,8 @@ meta.tags="monetization, inappbilling, promotions"
<p>
To listen for the <code>PURCHASES_UPDATED</code> intent, dynamically create a
{@link android.content.BroadcastReceiver} object and register it to listen
for <code>"com.android.vending.billing.PURCHASES_UPDATED"</code>. Register
the receiver by putting code like this in your activity's {@link
for <code>com.android.vending.billing.PURCHASES_UPDATED</code>. Register
the receiver by inserting code similar to the following in your activity's {@link
android.app.Activity#onResume onResume()} method:
</p>
@@ -172,36 +159,34 @@ registerReceiver(myPromoReceiver, promoFilter);</pre>
<p>
When the user makes a purchase, the system invokes your broadcast receiver's
{@link android.content.BroadcastReceiver#onReceive onReceive()} method. That
method should call <a href=
method must call <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a>
to see what purchases the user has made.
</p>
<p>
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:
<p>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:
</p>
<pre>unRegisterReceiver(myPromoReceiver);</pre>
<p class="note">
<strong>Note:</strong> You should not register this broadcast receiver in the
<strong>Note:</strong> 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 <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a>
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 <a href="{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a> when the user launches the app.
</p>
<h2 id="testing">Testing In-app Promotions</h2>
<p>
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.
</p>
@@ -211,18 +196,18 @@ registerReceiver(myPromoReceiver, promoFilter);</pre>
If the user redeems a promo code within the app's purchase flow, as described
in <a href=
"{@docRoot}google/play/billing/billing_integrate.html#billing-requests">Making
In-app Billing Requests</a>, the system invokes your activity's {@link
In-app Billing requests</a>, 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.
</p>
<h3 id="test-playstore">User redeems promo code in the Play Store</h3>
<h3 id="test-playstore">User redeems promo code in the Google Play Store</h3>
<p>
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.
</p>
<h4 id="test-app-uninstalled">App is not installed</h4>
@@ -231,16 +216,16 @@ registerReceiver(myPromoReceiver, promoFilter);</pre>
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.
</p>
<ol>
<li>User redeems a promo code for the app in the Play Store. The Play Store
<li>The user redeems a promo code for the app in the Play Store. The Play Store
prompts the user to install your app.
</li>
<li>User installs and launches your app. Verify that on startup, the app
<li>The user installs and launches your app. Verify that on startup, the app
calls <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a>
@@ -252,16 +237,16 @@ registerReceiver(myPromoReceiver, promoFilter);</pre>
<p>
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:
</p>
<ol>
<li>User redeems a promo code for the app in the Play Store. The Play Store
<li>The user redeems a promo code for the app in the Play Store. The Play Store
prompts the user to switch to your app.
</li>
<li>User launches your app. Verify that on startup, the app calls <a href=
<li>The user launches your app. Verify that on startup the app calls <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a>
and correctly detects the purchase the user made with the promo code.
@@ -274,15 +259,15 @@ registerReceiver(myPromoReceiver, promoFilter);</pre>
<p>
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 <code>PURCHASES_UPDATED</code>
intent. You should test the following sequence:
intent. Test the following sequence:
</p>
<ol>
<li>User launches the app. Verify that the app has properly registered itself to
<li>The user launches the app. Verify that the app has properly registered itself to
receive the <code>PURCHASES_UPDATED</code> intent.
</li>
<li>User launches the Play Store app and redeems a promo code for the app. The Play
<li>The user launches the Play Store app and redeems a promo code for the app. The Play
Store fires a <code>PURCHASES_UPDATED</code> 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);</pre>
<li>Your {@link android.content.BroadcastReceiver#onReceive onReceive()}
method should respond to the intent by calling <a href=
"{@docRoot}google/play/billing/billing_reference.html#getPurchases"
><code>getPurchases()</code></a>. Verify that it calls this method, and that
><code>getPurchases()</code></a>. Verify that your app calls this method and that
it correctly detects the purchase the user made with the promo code.
</li>
<li>User switches back to your app. Verify that the user has the purchased
<li>The user switches back to your app. Verify that the user has the purchased
item.
</li>
</ol>

159
docs/html/training/in-app-billing/preparing-iab-app.jd Executable file → Normal file
View File

@@ -31,23 +31,32 @@ next.link=list-iab-products.html
</div>
<a class="notice-developers-video wide"
href="https://www.youtube.com/watch?v=UvCl5Xx7Z5o">
href="https://www.youtube.com/watch?v=UvCl5Xx7Z5o" class="external-link">
<div>
<h3>Video</h3>
<p>Implementing Freemium</p>
</div>
</a>
<p>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.</p>
<p>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.</p>
<h2 id="GetSample">Download the Sample Application</h2>
<p>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.</p>
<p>To download the sample application:</p>
<p>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.</p>
<p>To download the sample application, follow these steps:</p>
<ol>
<li>Open Android Studio and then close any open projects until you are
presented with the welcome screen.</li>
<li>Choose <strong>Import an Android code sample</strong> from the
<strong>Quick Start</strong> list on the right side the window.</li>
<li>From the <strong>Quick Start</strong> list on the right side of the window, choose
<strong>Import an Android code sample</strong>.</li>
<li>Type {@code Trivial Drive} into the search bar and select the
<strong>Trivial Drive</strong> sample.</li>
<li>Follow the rest of the instructions in the <strong>Import Sample</strong>
@@ -56,66 +65,121 @@ presented with the welcome screen.</li>
</ol>
<p>Alternatively, you can use {@code git} to manually clone
the repository from <a
the repository from the <a
href="https://github.com/googlesamples/android-play-billing"
class="external-link">https://github.com/googlesamples/android-play-billing</a></p>
class="external-link">Google Samples</a> GitHub site.</p>
<h2 id="AddToDevConsole">Add Your Application to the Developer Console</h2>
<p>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 dont need to repeat these steps when you update the APK file for your application.</p>
<p>To add your application to the Developer Console:</p>
<p>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 dont need to repeat these steps when you update the APK file for
your application.</p>
<p>To add your application to the Developer Console, follow these steps:</p>
<ol>
<li>Go to the <a href="http://play.google.com/apps/publish">Google Play Developer Console</a> 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 <a href="http://www.google.com/wallet/merchants.html">Google payments</a> merchant account.</li>
<li>Click on <strong>Try the new design</strong> to access the preview version of the Developer Console, if you are not already logged on to that version. </li>
<li>In the <strong>All Applications</strong> tab, add a new application entry.
<li>Go to the <a href="http://play.google.com/apps/publish" class="external-link">
Google Play Developer Console</a>
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
<a href="http://www.google.com/wallet/merchants.html" class="external-link">
Google payments</a> merchant account.</li>
<li>In the <strong>All Applications</strong> tab, complete these steps to add a new
application entry:
<ol type="a">
<li>Click <strong>Add new application</strong>.</li>
<li>Enter a name for your new In-app Billing application.</li>
<li>Click <strong>Prepare Store Listing</strong>.</li>
</ol>
</li>
<li>In the <strong>Services & APIs</strong> 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.</li>
<li>In the <strong>Services & APIs</strong> 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.</li>
</ol>
<p>Your application should now appear in the list of applications in Developer Console.</p>
<h2 id="AddLibrary">Add the In-app Billing Library</h2>
<p>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.</p>
<p>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.</p>
<h3>New Project</h3>
<p>To add the In-app Billing Version 3 library to your new In-app Billing project:</p>
<p>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.</p>
<p>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.</p>
<h3>Adding in-app billing to a new project</h3>
<p>To add the In-app Billing Version 3 library to a new project, follow these steps:</p>
<ol>
<li>Copy the {@code TrivialDrive} sample files into your Android project.</li>
<li>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 <strong>Refactor</strong> > <strong>Rename</strong>.</li>
<li>Open the {@code AndroidManifest.xml} file and update the package attribute value to use the package name for your project.</li>
<li>Fix import statements as needed so that your project compiles correctly. In Android Studio, you can use this shortcut: press <strong>Ctrl+Shift+O</strong> in each file showing errors.</li>
<li>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}.</li>
<li>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 <strong>Refactor</strong> > <strong>Rename</strong>.</li>
<li>Open the {@code AndroidManifest.xml} file and update the package attribute value to
use the package name for your project.</li>
<li>Fix import statements as needed so that your project compiles correctly.
In Android Studio, you can press <strong>Ctrl+Shift+O</strong>
in each file showing errors.</li>
<li>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}.</li>
</ol>
<h3>Existing Project</h3>
<p>To add the In-app Billing Version 3 library to your existing In-app Billing project:</p>
<h3>Adding in-app billing to an existing project</h3>
<p>To add the In-app Billing Version 3 library to an existing project, follow these steps:</p>
<ol>
<li>Copy the {@code IInAppBillingService.aidl} file to your Android project.
<ul>
<li>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
<li>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.</li>
<li>In other dev environments: Create the following directory {@code /src/com/android/vending/billing} and copy the {@code IInAppBillingService.aidl} file into this directory.</li>
<li>In other dev environments: Create the following directory
{@code /src/com/android/vending/billing} and copy the {@code IInAppBillingService.aidl}
file into this directory.</li>
</ul>
</li>
<li>Build your application. You should see a generated file named {@code IInAppBillingService.java} in the {@code /gen} directory of your project.</li>
<li>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.</li>
<li>Build your application. You should see a generated file named
{@code IInAppBillingService.java}
in the {@code /gen} directory of your project.</li>
<li>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.</li>
</ol>
<p>Your project should now contain the In-app Billing Version 3 library.</p>
<h2 id="SetPermission">Set the Billing Permission</h2>
<p>Your app needs to have permission to communicate request and response messages to the Google Plays billing service. To give your app the necessary permission, add this line in your {@code AndroidManifest.xml} manifest file:</p>
<p>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:</p>
<pre>
&lt;uses-permission android:name="com.android.vending.BILLING" /&gt;
</pre>
<h2 id="Connect">Initiate a Connection with Google Play</h2>
<p>You must bind your Activity to Google Plays 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 dont have to manage the network connection directly.</p>
<p>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. </p>
<p class="note"><strong>Security Recommendation:</strong> 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.</p>
<p>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 dont have to
manage the network connection directly.</p>
<p>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.
</p>
<p class="caution"><strong>Security Recommendation:</strong> 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.</p>
<pre>
IabHelper mHelper;
@@ -130,13 +194,20 @@ public void onCreate(Bundle savedInstanceState) {
}
</pre>
<p>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.</p>
<p>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.</p>
<pre>
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() {
});
</pre>
<p>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 <a href="{@docRoot}training/in-app-billing/purchase-iab-products.html#QueryPurchases">Query Purchased Items</a> section.</p>
<p>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
<a href="{@docRoot}training/in-app-billing/purchase-iab-products.html#QueryPurchases">
Query Purchased Items</a> section.</p>
<p class="note"><strong>Important:</strong> Remember to unbind from the In-app Billing service when you are done with your activity. If you dont unbind, the open service connection could cause your devices performance to degrade. To unbind and free your system resources, call the {@code IabHelper}'s {@code dispose} method when your {@code Activity} is destroyed.</p>
<p class="caution"><strong>Important:</strong> Remember to unbind from the In-app Billing service
when you are done with your activity. If you dont 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.</p>
<pre>
&#64;Override
@@ -156,8 +236,3 @@ public void onDestroy() {
mHelper = null;
}
</pre>