android-Preparing Your In-app Billing Application,Establishing In-app Billing Products for Sale
>Preparing Your In-app Billing Application
> 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.
> Alternatively, you can use git
to
manually clone the repository fromhttps://github.com/googlesamples/android-play-billing
To
use the In-app Billing Version 3 features, you must add the IInAppBillingService.aidl
file to your Android project. This Android Interface Definition
Language (AIDL) file defines the interface to the Google Play service.To add the In-app Billing Version 3 library to your new In-app Billing project
<uses-permission android:name="com.android.vending.BILLING" />
To set up synchronous communication with Google Play, create an IabHelper
instance in your activity'sonCreate
method. In the constructor, pass in the 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.
IabHelper mHelper; @Override public void onCreate(Bundle savedInstanceState) { // ... String base64EncodedPublicKey; // compute your public key and store it in base64EncodedPublicKey mHelper = new IabHelper(this, base64EncodedPublicKey); }
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 IabHelper
's dispose
method when your Activity
is destroyed.
@Override public void onDestroy() { super.onDestroy(); if (mHelper != null) mHelper.dispose(); mHelper = null; }> Establishing In-app Billing Products for Sale
Important: The
In-app Billing Version 3 service only supports managed in-app products, so make sure that you specify that the purchase type is 'Managed' when you add new items to your product list in the Developer Console.
Warning: It
may take up to 2-3 hours after uploading the APK for Google Play to recognize your updated APK version. If you try to test your application before your uploaded APK is recognized by Google Play, your application will receive a ‘purchase cancelled’ response
with an error message “This version of the application is not enabled for In-app Billing.”
Note: When making
the query, you will need to specify the product IDs for the products explicitly. You can manually find the product IDs from the Developer Console by opening the In-app Products tab
for your application. The product IDs are listed under the column labeled Name/ID.
To retrieve the product details, call queryInventoryAsync(boolean, List, QueryInventoryFinishedListener)
on your IabHelper instance.
- The first input argument indicates whether product details should be retrieved (should be set to
true
). - The
List
argument consists of one or more product IDs (also called SKUs) for the products that you want to query. - Finally, the
QueryInventoryFinishedListener
argument specifies a listener is notified when the query operation has completed and handles the query response.
IabHelper.QueryInventoryFinishedListener mQueryFinishedListener = new IabHelper.QueryInventoryFinishedListener() { public void onQueryInventoryFinished(IabResult result, Inventory inventory) { if (result.isFailure()) { // handle error return; } String applePrice = inventory.getSkuDetails(SKU_APPLE).getPrice(); String bananaPrice = inventory.getSkuDetails(SKU_BANANA).getPrice(); // update the UI } }
相關文章
- android-Purchasing In-app Billing Products,Testing Your In-app Billing ApplicationAndroidAPP
- User Exits For Billing
- In-App Purchase 內購丟單、串單處理APP
- 雲音樂中 In-App Purchase 實踐總結篇APP
- Retroactive Billing – VFRB Modification to add credit/debit line
- emSecure Use Digital Signatures to protect your productsGit
- Trim your pubic hair hard times pills for saleAI
- 將C4C Service Request中的summary和其他附件同步到ERP的Billing Request去
- SAP S/4HANA Cloud 上 in-app 和 side-by-side 兩種擴充套件方式的介紹CloudAPPIDE套件
- No suitable application records were found. Verify your bundle ideUIAPPIDE
- fitflop sale as well as thorough
- How to get propose products in Sales Order
- Under the conditions with the lancel handbags sale
- How to calculate the sale order item costs?
- 急~~~Error establishing socket異常。Error
- 3 Complementary Products and Strategic Partnerships
- Your Prediction Gets As Good As Your DataGo
- [ABC132F] Small Products 題解
- Our yoga instruction software are parajumpers sale roundedStruct
- Another excuse is usually to be parajumpers sale certain safetyAI
- Although it does not provide the most Parajumpers On SaleIDE
- Design Patterns: Solidify Your C# Application Architecture with Design Patterns中文版(中篇) (轉)SolidC#APP
- Design Patterns: Solidify Your C# Application Architecture with Design Patterns中文版(下篇) (轉)SolidC#APP
- Postkey 中sale related選項含義
- Cheap ghd straighteners for sale why he is shuttingAI
- Your title
- Design Patterns: Solidify Your C# Application Architecture with Design Patterns中文版(尾篇二) (轉)SolidC#APP
- Design Patterns: Solidify Your C# Application Architecture with Design Patterns中文版(尾篇一) (轉)SolidC#APP
- Prettier your projectProject
- 12c-Say goodbye to your backup when dropping your PDBGo
- In your opinion with 6 sentences
- deploy-your-site
- translate-your-site
- talk-to-your-data
- Catch Application Exceptions in a Windows Forms ApplicationAPPExceptionWindowsORM
- Scan Your Truck Using Nexiq Adapter: Simplifying Your Diagnostic ProcessAPT
- How Good Are Your Opinion 2Go
- Running the app on your deviceAPPdev