as

Settings
Sign out
Notifications
Alexa
亚马逊应用商店
Ring
AWS
文档
Support
Contact Us
My Cases

as

开发
测试
应用发布
盈利
用户参与
设备规格
资源

开始使用Appstore SDK示例应用

开始使用Appstore SDK示例应用

使用Appstore SDK中包含的示例应用,通过以下步骤开始使用应用内购买 (IAP)。有关如何实现IAP API的详细说明,请参阅实现Appstore SDK IAP

1. 下载示例应用

示例应用包含在Appstore SDK中,后者可以在下面下载。

此下载项包括IAP JAR文件、API文档和Java示例应用。

当您准备好将Appstore SDK集成到自己的应用中时,可使用Maven Central将Appstore SDK添加到您的项目中。这是开始使用应用内购买 (IAP) 的首选选项,因为您可以直接在Android Studio和Gradle构建自动化系统中更新Appstore SDK。当有SDK更新可用时,Maven Central会自动向您发送通知。您可以按照集成Appstore SDK中的说明进行操作。

2. 在Android Studio中设置示例应用

如果使用Android Studio作为IDE,您可以导入示例项目,将它们导出为APK并在Fire设备上运行它们。

要使用Kotlin示例应用,请在此处从GitHub克隆或下载IAP Kotlin示例应用:

对于Java示例应用,请按照以下步骤操作:

  1. 将Appstore_SDK_<版本>.zip文件的内容解压到您的本地计算机上。
  2. 启动Android Studio并将IAP示例应用导入您的工作区:
    1. 在“Welcome to Android Studio”(欢迎使用Android Studio)屏幕的More Actions(更多操作)菜单(右上角的三个堆叠的点),选择Import Project (Eclipse ADT, Gradle, etc.)​(导入项目 [Eclipse ADT、Gradle等])以打开项目导入窗口。
      或者在Android Studio中选择File(文件)> New(新建)> Import Project(导入项目)。
    2. 导航到SDK zip文件内容的解压位置,然后展开/Appstore_SDK_<版本>/examples目录。
    3. 为其中一个IAP示例项目选择文件夹,然后单击OK(确定)。
    4. 对每个示例应用重复上述步骤。
  3. 为其中一个示例应用生成APK:
    1. 在设备上启用开发者选项和USB调试,并将设备连接到开发计算机。如果在连接设备方面需要帮助,请参阅通过ADB连接到Fire平板电脑
    2. 在Android Studio中,选择Run(运行)> Run 'app'(运行“应用”),将应用安装到该设备上。

您现在应该能够在Fire设备上运行此示例应用了。

请注意,在将实际应用提交到亚马逊应用商店时,亚马逊签名将用于您的应用,无论您提交的是已签名还是未签名的APK。

3. 设置App Tester

亚马逊提供了App Tester工具来对IAP执行单元测试。您可以使用IAP示例应用来测试此工具。

安装App Tester并在在App Tester上运行示例应用:

  1. 按照安装并配置App Tester中的说明操作。
  2. 从示例应用中,使用adb push命令,将amazon.sdktester.json文件复制到您设备上的/mnt/sdcard/amazon.sdktester.json路径中:

    $ adb push <您的JSON文件夹>/amazon.sdktester.json /mnt/sdcard/
    
  3. 按照App Tester用户指南中的说明进行操作,了解有关使用App Tester测试应用的更多信息。如果您在设置要使用App Tester进行检查的测试案例这方面需要帮助,请参阅为IAP定义并执行测试案例

4. 提交应用和应用内商品

测试完应用后,即可向亚马逊提交应用和应用内商品。

请参阅创建并提交IAP商品


Last updated: 2025年8月20日

").insertBefore(this); } }); }); $(document).ready(function() { if ($("#jumpoffset").length) { var scrollhash = document.getElementById('jumpoffset'); scrollhash.scrollIntoView(true); if (location.hash) { location.href = location.hash; } else { var scrollbody = document.querySelector('.mainColumn'); scrollbody.scrollIntoView(true); window.scroll(0, -500); } } }); $(document).ready(function() { if ($("#jump").length) { var scrollold = document.getElementById('jump'); scrollold.scrollIntoView(true); window.scroll(0, -100); if (location.hash) { location.href = location.hash; } } }); //resize container on local builds $(document).ready(function() { if (window.location.href.indexOf("/127.0.0.1:4000/") > -1) { document.querySelector('.container-fluid').style.position = 'fixed'; } }); //add underline to headers $(document).ready(function() { if ($(".productTitle").is(':contains("Alexa Skills Kit")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Alexa Skills Kit")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); } if ($(".productTitle").is(':contains("Alexa Presentation Language (APL)")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Alexa Skills Kit")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); } if ($(".productTitle").is(':contains("Alexa Connect Kit")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Alexa Connect Kit")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); } if ($(".productTitle").is(':contains("A/B Testing")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Alexa Skills Kit")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); } if ($(".productTitle").is(':contains("Alexa Smart Properties")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Alexa Smart Properties")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); } if ($(".productTitle").is(':contains("Alexa Conversations Developer Guide")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Alexa Skills Kit")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); } if ($(".productTitle").is(':contains("Alexa Design Guide")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Alexa Design Guide")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); $(".dppnItem a").each(function() { if ($(this).is(':contains("Alexa Design Guide")')) { $(this).css("padding", "0"); } }); } if ($(".productTitle").is(':contains("Alexa Gadgets Toolkit")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Alexa Gadgets Toolkit")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); $(".dppnItem a").each(function() { if ($(this).is(':contains("Alexa Gadgets Toolkit")')) { $(this).css("padding", "0"); } }); } if ($(".productTitle").is(':contains("Alexa Voice Service")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Alexa Voice Service")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); } if ($("h1").is(':contains("Alexa Reference Content")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Reference")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); } if ($("h1").is(':contains("Alexa Videos")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Videos")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); } if ($("h1").is(':contains("Alexa Code Samples")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Code Samples")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); } if ($("h1").is(':contains("Documentation Home")')) { $(".dppnItem a").each(function() { if ($(this).is(':contains("Home")')) { $(this).css("border-bottom", "1.3px solid #FFFFFF"); } }); } }); $(document).ready(function () { const myScrollspy = $("#myScrollspy"); if (myScrollspy.length) { const containsList2orList3 = myScrollspy.find(".list2, .list3").length > 0; if (containsList2orList3) { myScrollspy.css("display", "block"); $(".fa.fa-info-circle").show(); } else { myScrollspy.css("display", "none"); $(".fa.fa-info-circle").hide(); } } }); /** * This function moves the 'page-not-translated' section from its original position * to a new position after the 'atd-categories-header' and ensures it is displayed * only in the new location. This is achieved by hiding the section initially, * moving it, and then displaying it again once it is in the correct position. */ $(document).ready(function() { const $pageNotTranslatedMessage = $('#page-not-translated'); const $desktopCategoriesHeader = $('.navigation-header.atd-categories-header'); const $mobileToggleHeader = $('.mobile-toggle'); if ($pageNotTranslatedMessage.length) { if ($mobileToggleHeader.length) { $pageNotTranslatedMessage.insertAfter($mobileToggleHeader); } else if ($desktopCategoriesHeader.length) { $pageNotTranslatedMessage.insertAfter($desktopCategoriesHeader); } $pageNotTranslatedMessage.show(); } }); // Function to handle smooth scrolling to target elements when links are clicked $(document).ready(function () { $('.customspy a, .mainColumn a').on('click', function (event) { const targetId = $(this).attr('href'); if (targetId && targetId.startsWith('#')) { event.preventDefault(); const targetElement = document.querySelector(`[id="${targetId.replace('#', '')}"]`); if (targetElement) { const hash = targetId.substring(1); window.history.pushState(null, '', `#${hash}`); targetElement.scrollIntoView(true); window.scroll(0, -500); } } }); }); window.addEventListener('DOMContentLoaded', function () { const targetId = window.location.hash; if (targetId) { const targetElement = document.querySelector(targetId); if (targetElement) { setTimeout(() => { targetElement.scrollIntoView(true); window.scrollBy(0, -500); }, 10); } } }); function activateContentBasedOnHash() { const currentHash = window.location.hash.substring(1); if (currentHash) { const contentElement = document.getElementById(currentHash); if (contentElement) { activateTabAndContent(contentElement); } } } function activateTabAndContent(contentElement) { const tabSection = contentElement.closest('.tab-pane'); if (tabSection) { const parentTabLink = document.querySelector(`a[href='#${tabSection.id}']`); if (parentTabLink) { const parentNavTabs = parentTabLink.closest('.nav-tabs'); if (parentNavTabs) { parentNavTabs.querySelectorAll('.nav-link').forEach(link => { link.classList.remove('active', 'show'); }); parentTabLink.classList.add('active', 'show'); } const parentTabContent = tabSection.closest('.tab-content'); if (parentTabContent) { parentTabContent.querySelectorAll('.tab-pane').forEach(tab => { tab.classList.remove('active', 'show'); }); tabSection.classList.add('active', 'show'); } } } } function scrollToHashWithOffset() { const tabHash = window.location.hash; const targetTabLink = document.querySelector(`.nav-tabs a[href="${tabHash}"]`); const mainContentColumn = document.querySelector('.inline'); if (targetTabLink && mainContentColumn) { const totalHeaderHeight = getTotalHeaderHeight() + 40; targetTabLink.scrollIntoView({behavior: 'smooth', block: 'start'}); setTimeout(() => { mainContentColumn.scrollBy(0, -totalHeaderHeight); }, 20); } } function getTotalHeaderHeight() { return [...document.querySelectorAll('.atd-services-header, .atd-categories-header')] .reduce((total, header) => total + (header ? header.offsetHeight : 0), 0); } function handleClick(event) { event.preventDefault(); const link = event.currentTarget; const hash = link.getAttribute('href').substring(1); const contentElement = document.getElementById(hash); if (contentElement) { activateTabAndContent(contentElement); scrollToHashWithOffset(); } } function handleBackToTopClick(event) { event.preventDefault(); const mainContentColumn = document.querySelector('.inline'); if (mainContentColumn) { mainContentColumn.scrollTo({top: 0, behavior: 'smooth'}); } window.scrollTo({top: 0, behavior: 'smooth'}); } document.addEventListener('DOMContentLoaded', () => { activateContentBasedOnHash(); scrollToHashWithOffset(); const myScrollspy = document.getElementById('myScrollspy'); if (myScrollspy) { myScrollspy.querySelectorAll('a[href^="#"]').forEach(link => { link.addEventListener('click', handleClick); }); } document.querySelectorAll('.dpfBackToTopLink, .backToTop').forEach(link => { link.addEventListener('click', handleBackToTopClick); }); }); // Show tab link as selected when clicked $(document).ready(function() { $('.nav-tabs > li > a').on('click', function(e) { e.preventDefault(); $(this).tab('show'); $(this).addClass('active show'); }); }); // Fix for when version dropdown is on the same page as nav tab dropdown // closes other dropdown menu to avoid overlap/usability issues $(document).ready(function() { // Version selector dropdown $('.versionsButton').click(function(e) { // Close the nav tab dropdown if open $('.nav-link.dropdown-toggle').siblings('.dropdown-menu').removeClass('show'); }); // Nav tab selector dropdown $('.nav-link.dropdown-toggle').click(function(e) { // Close the version dropdown if open $('.versionsButton').siblings('.dropdown-menu').removeClass('show'); }); }); // Handle active state management for dropdown menu in nav-tabs // Fixes edge case issues for when version selector dropdown and // nav-tab dropdown appear on the same page $(document).ready(function() { // Function to deactivate all tab panes and reset dropdown items function deactivateAllTabs() { $('.position .nav-item.dropdown .dropdown-menu .dropdown-item').each(function() { const targetId = $(this).attr('href'); $(targetId).removeClass('active show'); $(this).removeClass('active show'); }); } // Store the original pushState function const originalPushState = history.pushState; // Create a custom event for pushState const pushStateEvent = new Event('pushState'); // Override pushState history.pushState = function() { originalPushState.apply(this, arguments); // Dispatch the custom event window.dispatchEvent(pushStateEvent); }; // Add pushState listener window.addEventListener('pushState', function() { const params = new URLSearchParams(window.location.search); const vValue = params.get('v'); // Handle query parameter change from version selector if (vValue) { // Remove active classes from all tabs deactivateAllTabs(); $('.position').each(function() { var firstTabPane = $(this).find('.tab-pane').first(); if (firstTabPane.length > 0) { var tabId = firstTabPane.attr('id'); var dropdownItem = $('.dropdown-menu .dropdown-item[href="#' + tabId + '"]'); // Make first tab in each version active dropdownItem.addClass('active show'); firstTabPane.addClass('active show'); } }); } }); // Handle dropdown item clicks $('.position .nav-item.dropdown .dropdown-menu .dropdown-item').click(function(e) { e.preventDefault(); // Remove active classes from all tabs deactivateAllTabs(); // Add active class to clicked item $(this).addClass('active show'); // Show corresponding tab content const targetId = $(this).attr('href'); $(targetId).addClass('active show'); }); // Handle initial load from URL hash if (window.location.hash) { const tabId = window.location.hash; if ($(tabId).length) { // Deactivate all tabs first deactivateAllTabs(); // Activate the correct tab and content $(`.position .nav-item.dropdown .dropdown-menu .dropdown-item[href="${tabId}"]`).addClass('active show'); $(tabId).addClass('active show'); } } }); // Fix issue when anchor linking into a tab with a dropdown menu $(document).ready(function() { // Handle initial load from URL hash if (window.location.hash) { const tabId = window.location.hash; if ($(tabId).length) { // Deactivate active links in dropdown $('.nav-item.dropdown .dropdown-menu .dropdown-item').each(function() { $(this).removeClass('active show'); }); } } });