(2)Establishing In-app Billing Products for Sale
Before publishing your In-app Billing application, you'll need to define the product list of digital goods available for purchase in the Google Play Developer Console.
Specify In-app Products in Google Play
From the Developer Console, you can define product information for in-app products and associate the product list with your application.
To add new in-app products to your product list:
- Build a signed APK file for your In-app Billing application. To learn how to build and sign your APK, see Building Your Application for Release. Make sure that you are using your final (not debug) certificate and private key to sign your application.
- In the Developer Console, open the application entry that you created earlier.
- Click on the APK tab then click on Upload new APK. Upload the signed APK file to the Developer Console. Don’t publish the app yet!
- Navigate to the uploaded app listing, and click on In-app Products.
- Click on the option to add a new product, then complete the form to specify the product information such as the item’s unique product ID (also called its SKU), description, price, and country availability. Note down the product ID since you might need this information to query purchase details in your application later.
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.
- Once you have completed the form, activate the product so that your application can purchase it.
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.”
Query Items Available for Purchase
You can query Google Play to programmatically retrieve details of the in-app products that are associated with your application (such as the product’s price, title, description, and type). This is useful, for example, when you want to display a listing of unowned items that are still available for purchase to users.
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.
If you use the convenience classes provided in the sample, the classes will handle background thread management for In-app Billing requests, so you can safely make queries from the main thread of your application.
The following code shows how you can retrieve the details for two products with IDs SKU_APPLE
and SKU_BANANA
that you previously defined in the Developer Console.
List additionalSkuList =newList(); additionalSkuList.add(SKU_APPLE); additionalSkuList.add(SKU_BANANA); mHelper.queryInventoryAsync(true, additionalSkuList, mQueryFinishedListener);
If the query is successful, the query results are stored in an Inventory
object that is passed back to the listener.
The following code shows how you can retrieve the item prices from the result set.
IabHelper.QueryInventoryFinishedListener mQueryFinishedListener =newIabHelper.QueryInventoryFinishedListener(){ publicvoid 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 } }
相关推荐
完整英文电子版 JEDEC JESD22-B130:2022 Test Method for Establishing X-Ray Total Dose Limit for DRAM Devices-(建立 DRAM 器件 X 射线总剂量限值的测试方法)。本测试方法作为标准化程序提供,通过测量设备受到...
2. 生成性对抗网络与条件图像合成 GANs由两部分组成:生成器(Generator)和判别器(Discriminator)。生成器负责根据输入条件(如加工参数)创建新的微观结构图像,而判别器则试图区分这些生成的图像与真实图像。...
PaloAlto
2. **实际测量与仿真对比**: - 对于测试样机,HyperLynx 8.0 PI准确地预测了含有0603电容和平面腔体的PCB结构中的阻抗特性。 - 实验结果显示,仿真得到的阻抗曲线与实际测量值非常接近,特别是在涉及电容器和平面...
2. **多样性挑战**:不同文化背景、性别、年龄等因素可能造成沟通障碍。 3. **技术变迁**:新技术的应用改变了沟通的方式和效率。 4. **团队环境**:团队的文化氛围会影响成员间的沟通方式。 #### 五、沟通类型 1....
ACPI (Advanced Configuration and ...is an open industry specification establishing industry-standard interfaces for OSdirected configuration and power management on laptops, desktops, and servers.
The successful integration of Vue.js, uni-app, GO, and YApi, among other tools, demonstrates the potential of technology in revolutionizing the educational landscape for international students in ...
是一个免费的Material Bootstrap Admin,其灵感来自Google的Material Design,它的设计新颖新颖。 我们很高兴通过易于使用且美观的组件来介绍我们对材料概念的看法。 Material Dashboard是基于流行的Bootstrap框架...
This book describes best practices for successful FPGA design. It is the result of the author’s meetings with hundreds of customers on the challenges facing each of their FPGA design teams. By ...
This paper is included in the Proceedings of the 2015 USENIX Annual Technical Conference (USENIC ATC ’15).July 8–10, 2015 • Santa Clara, CA, USAISBN 978-1-931971-225Open access to the Proceedings ...
There are powerful case studies and real-world deployments clearly illustrating that Docker consistently contributes to establishing and sustaining IT environments in minutes rather than in months....
D2D communication aims at establishing a direct communication link between the user equipments, located in the close proximity of each other, instead of traversing through the core network. ...
authors, only for the purpose of establishing the specification of a codec. VERSION ------- This is version 1.4. ---------------------------------------------------------------------------- ...
### Kanban for the Shopfloor: An In-depth Exploration #### Introduction to Kanban and Its Benefits **Kanban** is a methodology derived from the Lean Six Sigma approach that emphasizes efficiency and...
2. **可靠性**:系统必须始终如一地表现良好,避免意外错误或不一致的行为。 3. **可控性**:用户应该能够控制代理的行为,包括设置偏好、限制权限等。 4. **可预测性**:代理的行为应是可预测的,这样用户可以预见...