am 3fc61015: am 9a6aa0ff: am d126294a: Docs: Adding Android Studio instructions for adding IAB service. automerge: 77760e7
* commit '3fc61015f51a3f8ae8516b5e31d7f867f48b6d84': Docs: Adding Android Studio instructions for adding IAB service.
This commit is contained in:
@@ -78,14 +78,16 @@ next.link=list-iab-products.html
|
|||||||
<ol>
|
<ol>
|
||||||
<li>Copy the {@code IInAppBillingService.aidl} file to your Android project.
|
<li>Copy the {@code IInAppBillingService.aidl} file to your Android project.
|
||||||
<ul>
|
<ul>
|
||||||
<li>If you are using Eclipse: Import the {@code IInAppBillingService.aidl} file into your {@code /src} directory.</li>
|
<li>In Android Studio: Create a directory named {@code aidl} under {@code src/main}, add a new
|
||||||
<li>If you are developing in a non-Eclipse environment: Create the following directory {@code /src/com/android/vending/billing} and copy the {@code IInAppBillingService.aidl} file into this directory.</li>
|
package {@code com.android.vending.billing} in this directory, and import the
|
||||||
|
{@code IInAppBillingService.aidl} file into this package.</li>
|
||||||
|
<li>In Eclipse: Import the {@code IInAppBillingService.aidl} file into your {@code /src} 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>
|
</ul>
|
||||||
</li>
|
</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>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>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>
|
</ol>
|
||||||
|
|
||||||
<p>Your project should now contain the In-app Billing Version 3 library.</p>
|
<p>Your project should now contain the In-app Billing Version 3 library.</p>
|
||||||
|
|
||||||
<h2 id="SetPermission">Set the Billing Permission</h2>
|
<h2 id="SetPermission">Set the Billing Permission</h2>
|
||||||
@@ -106,7 +108,7 @@ IabHelper mHelper;
|
|||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
// ...
|
// ...
|
||||||
String base64EncodedPublicKey;
|
String base64EncodedPublicKey;
|
||||||
|
|
||||||
// compute your public key and store it in base64EncodedPublicKey
|
// compute your public key and store it in base64EncodedPublicKey
|
||||||
mHelper = new IabHelper(this, base64EncodedPublicKey);
|
mHelper = new IabHelper(this, base64EncodedPublicKey);
|
||||||
}
|
}
|
||||||
@@ -120,15 +122,15 @@ mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
|
|||||||
if (!result.isSuccess()) {
|
if (!result.isSuccess()) {
|
||||||
// Oh noes, there was a problem.
|
// Oh noes, there was a problem.
|
||||||
Log.d(TAG, "Problem setting up In-app Billing: " + result);
|
Log.d(TAG, "Problem setting up In-app Billing: " + result);
|
||||||
}
|
}
|
||||||
// Hooray, IAB is fully set up!
|
// Hooray, IAB is fully set up!
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
</pre>
|
</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 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} gets destroyed.</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 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.</p>
|
||||||
|
|
||||||
<pre>
|
<pre>
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
Reference in New Issue
Block a user