android-Preparing Your In-app Billing Application,Establishing In-app Billing Products for Sale
来源:互联网 发布:淘宝美工应聘流程 编辑:程序博客网 时间:2024/05/16 06:30
>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;@Overridepublic 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.
@Overridepublic 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-Preparing Your In-app Billing Application,Establishing In-app Billing Products for Sale
- android-Purchasing In-app Billing Products,Testing Your In-app Billing Application
- Google In App Billing
- In-app Billing 概述
- Android in-app billing: 关于 RESTORE_TRANSACTIONS
- 在中国大陆调试ANDROID IN-APP-BILLING
- 在中国大陆调试Android In-app-billing
- Android支付接入:Google In-app-Billing
- 在中国大陆调试Android In-app-billing
- 在中国大陆调试Android In-app-billing
- Google Play In-app Billing
- Google Play In-app Billing
- Google Play In-app Billing
- Google Play In-app Billing
- Testing In-app Billing(转)
- google In-app Billing FAQ
- google play in app billing
- Google Play In-app Billing
- 使用Oracle自带的系统包和过程监控其它会话SQL语句的执行计划等信息
- 基于SocketChannel的即时聊天程序
- POJ 1006 Biorhythms
- utunbu启动进入文本界
- uva725 - Division
- android-Preparing Your In-app Billing Application,Establishing In-app Billing Products for Sale
- 摒弃以往的工作方法
- ubuntu上面装matlab
- 03-lvs-persistence
- Unity问答第3期
- uva673-栈-(字符读取和清空缓冲区)
- 别拦我,让我悲伤一会
- Android 5.1 ActivityManagerService启动
- iOS UI自动化——Instruments常用语法