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 } }
相關文章
- Retroactive Billing – VFRB Modification to add credit/debit line
- In-App Purchase 內購丟單、串單處理APP
- 雲音樂中 In-App Purchase 實踐總結篇APP
- SAP SD 以PDF格式顯示BILLING的輸出格式
- 將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
- How to get propose products in Sales Order
- [ABC132F] Small Products 題解
- Establishing SSL connection without server's identity verification is not recommended.ServerIDE
- [LeetCode] 2064. Minimized Maximum of Products Distributed to Any StoreLeetCodeZed
- Your title
- Scan Your Truck Using Nexiq Adapter: Simplifying Your Diagnostic ProcessAPT
- Error establishing a database connection 的解決方法(發現黑客入侵)ErrorDatabase黑客
- Prettier your projectProject
- Offering Your Seat
- Structuring Your TensorFlow ModelsStruct
- translate-your-site
- deploy-your-site
- your Android sdk is missingAndroid
- talk-to-your-data
- connect your tunnel to CloudflareCloud
- SAP 電商雲 Spartacus UI 和 CPQ Configurable Products 的整合UI
- Creating your first iOS FrameworkiOSFramework
- RuneScape - To verify your level of combatBAT
- 動物眼影一週狂Sale 20萬銷量,完美日記怎麼做到的?
- web_applicationWebAPP
- 2.3.3.4 Application PatchAPP
- 2.3.3.3 Application UpgradeAPP
- 2.3.3.2 Application InstallationAPP
- 2.3.3 Application MaintenanceAPPAINaN
- 2.3.1.4 Application SeedAPP
- 2.3.1.3 Application PDBsAPP
- 2.3.1.2 Application RootAPP
- Visual Basic for ApplicationAPP
- 題解:AT_arc116_b [ARC116B] Products of Min-Max
- 錯誤內容:You have an error in your SQL syntax; check the manual that corresponds to your MySQL serverErrorMySqlServer
- Project Management - 2) Estimate Your WorkProject
- Boost Your Strategy With The Content Marketing Tools