Appstore Blogs

Appstore Blogs

Want the latest?

appstore topics

Recent Posts

Archive

Showing posts tagged with kindle fire

February 10, 2014

David Isbitski

Setting up your Kindle Fire device for testing and debugging is a simplified process thanks to Android Debug Bridge (ADB) support.  Since questions around ADB driver support have come up on Stack Overflow and our developer forums I thought it would be beneficial to walk through the setup process. 

Certain development tools referenced in this post are provided by third parties, not by Amazon. Any links to these tools will take you to third-party sites to download and install them.

Getting Started

Note – this post was updated on April 16th, 2014 to reflect changes in the Amazon Android SDK addon.

First, ensure your development computer has at least one package of Kindle Fire system images installed. This is critical because the package includes the vendor identification needed for ADB to recognize any of the physical Kindle Fire tablets.  This is done through the following steps:

  • Ensure you have the Android SDK already installed
  • Launch the Android SDK Manager
  • Under Tools, select Manage Add-On Sites, and enter the following url: http://kindle-sdk.s3.amazonaws.com/addon.xml

  • Select Close and wait for the list of available packages to refresh
  • Select Kindle Fire USB Driver, Kindle Fire Device Definitions, and optionally the Amazon AVD Launcher.

  • Select at least one Kindle Fire image so that vendor information is available for ADB.  I’ve chosen to select the three Kindle Fire 3rd Generation images (API Level 17).

  • Accept the license agreements and install.

For complete information about setting up your development computer and installing the SDK packages, see Setting Up Your Development Environment.

Uninstalling existing Windows drivers

If you installed a previous version of the Kindle Fire USB driver then take the following steps to remove the previous USB device driver and force re-installation of the driver.

  • Connect your Kindle Fire tablet to the USB port on your development computer.
  • On the development computer, from the Start menu, right-click Computer, and then click Manage.
  • In the left pane, under Computer Management, expand System Tools, and then click Device Manager.
  • In the right pane, expand Portable Devices.

  • Next, Right-click Kindle and then click Properties.
  • In the Kindle Properties window, on the Driver tab, click Uninstall, and then Confirm.

  • Finally, unplug your Kindle Fire tablet from your computer.

Enabling ADB on the Kindle Fire

Next, we need to turn on ADB support on our actual Kindle Fire device.  Follow these steps:

  • On your Kindle Fire tablet, go to Settings.
  • On a third-generation Kindle Fire tablet, tap Device.  On a second-generation Kindle Fire tablet, tap Security.  First-generation Kindle Fires already have ADB enabled by default so no action is needed.
  • Set Enable ADB to On, and then accept the pop-up warning message.       

As a security precaution, you should set Enable ADB to Off when you are not trying to connect to the Kindle Fire tablet to your development computer.

Installing Windows ADB drivers

First, ensure you have enabled ADB on the Kindle first as described above.  For the USB driver to install correctly, Windows must recognize the device as Android Composite ADB Interface during installation. If ADB is not enabled, Windows instead recognizes the device as Portable Devices.

Do the following to install the Kindle Fire USB driver:

  1. In your Android SDK directory, at \extras\amazon\kindle_fire_usb_driver, run KindleDrivers.exe, and then follow the instructions on the screen.

  1. Connect your Kindle Fire tablet to a USB port on your development computer.
  2. From Start, click Control Panel, and then select Device Manager.
  3. In Device Manager, under Kindle Fire, verify that the device appears as Android Composite ADB Interface.

Next, do the following to detect your Kindle Fire tablet through ADB:

  1. Open a command prompt window.
  2. Change directory to your Android SDK platform-tools directory.
  3. Run the following commands and confirm that the serial number for your Kindle Fire tablet appears in the list of devices.

adb kill-server

adb start-server

adb devices

If the serial number does not appear after running adb devices, do the following:

  1. Change directory to your Android SDK tools directory.
  2. Run the following command:

android update adb

  1. Change directory back to your Android SDK platform-tools directory.
  2. Run the following commands:

adb kill-server

adb start-server

adb devices

If your Kindle Fire device still does not show up you may need to reboot your development machine and then try again.

Installing Mac OSX ADB drivers

Perform the following steps if your development computer runs OS X:

  1. Connect your Kindle Fire tablet to a USB port on your development computer.
  2. Open a terminal shell and navigate to your Android SDK tools directory.
  3. Run the following command to update ADB.

./android update adb

4. In the terminal shell, navigate to your Android SDK platform-tools directory.

5. Run the following commands and confirm that the serial number for your Kindle Fire tablet appears in the list of devices.

               

If your Kindle Fire device does not show up in the list of devices you may need to reboot your development machine and then try again.

You should now be able to fully test with your Kindle Fire device over the Android Debug Bridge.  For additional information on enabling ADB for Kindle Fire Devices, see Setting Up Your Kindle Fire Tablet for Testing.

-Dave (@TheDaveDev)

 

February 06, 2014

Peter Heinrich

If you develop apps or games with Unity, you may already be using Amazon’s GameCircle plug-in for Unity to integrate cross-platform leaderboards, achievements, and game data synchronization.  The plug-in works on iOS, Android, and Fire OS, connecting your app to Amazon’s GameCircle service.  Its leaderboards and achievements encourage friendly competition and replay, while its Whispersync for Games component backs up game data to the cloud, improving the customer experience.  With GameCircle, gamers won’t lose their progress if they reset their device or buy a new one.

If you haven’t used the GameCircle plug-in yet, you can now download it from the Scripting/Integration section of the Unity Asset Store.  Accessible directly from within the Unity development environment, the Unity Asset Store makes it fast and convenient to add editor or game functionality through third-party extensions like the GameCircle plug-in.

 

 

This official GameCircle plug-in is compatible with iOS and Android phones and tablets, as well as Kindle Fire, Kindle Fire HD, and Kindle Fire HDX devices.  Add the plug-in to your project to access GameCircle leaderboards, achievements, and Whispersync for Games.

In addition, the GameCircle plug-in also works with the Unity Social API, which provides a unified interface to social back-ends such as Game Center and Xbox Live.  Set the active social platform to GameCircle and calls to the Unity Social API will pass through to the GameCircle service in the same way:

#if UNITY_IOS || UNITY_ANDROID
Social.Active = GameCircleSocial.Instance;    
#endif

Since Unity’s Social API is designed to be a generic interface that works across many services, it doesn’t support every feature of every back-end.  GameCircle leaderboards and achievements work seamlessly, for example, but Unity’s Social API provides no hooks for game data synchronization.  To use some advanced features of GameCircle, like Whispersync for Games, simply call the API through the normal GameCircle interface.  It’s easy to use the two APIs side-by-side, and the plug-in includes a sample scene to help you get GameCircle and Unity’s Social API up and running together.

Check out the official GameCircle plug-in in the Unity Asset Store.  It’s easier than ever to get started integrating GameCircle’s leaderboards, achievements, and Whispersync for Games in your Unity-based game for most mobile devices.  You can also visit our developer portal for more detailed information about using GameCircle and Unity together, as well as links to help you call other Amazon services from your Unity projects.

 

January 30, 2014

Russell Beattie

Creating an application using Amazon's Mobile App Distribution Program is a great way for developers who have hosted web apps to create downloadable apps available on the Amazon Appstore. Web app developers benefit from the increased discoverability that the store provides when users are searching for new apps, as well as being reminded to use the web app by the icon on their device's home screen afterwards. In addition, all of a user’s linked devices that use the Amazon Appstore will have the icon waiting in their Cloud list of apps as well.

And because web apps are hosted online, developers have increased flexibility to re-use existing assets and make changes or fixes to the app quickly and easily, without having to re-create a new app that has to be re-installed by the end user. But what happens if the user wants to use the app offline? Obviously, if the app relies on live server-side content - such as streaming videos or airline reservations - then obviously it's not going to work. But if the web app is self-contained and doesn't need to talk to a server for its core functionality - like most games - then being able to take the app offline is something that should be an option for users.

Happily, enabling your web app to be used offline can be done using HTML5's built-in Application Cache with only a few small changes to your code. Below I'll outline the steps you need to take to create a basic offline web app. It's surprisingly easy to set up, but beware! Application Cache has a well deserved reputation for being difficult for developers to get a handle on.

Offline Web App Walkthrough

1. Create Manifest File

The first thing you need to do is create an HTML5 manifest text file with a list of every asset file your web app requires - HTML, JavaScript, CSS, images, icons, fonts, etc. The manifest file can have any name you choose, but we'll use app.appcache to be clear and to avoid overlap with other types of manifest files.

Here's the content of a basic manifest file:

CACHE MANIFEST 
# Version 1.0 
CACHE: 
main.js 
main.css 
logo.png 
NETWORK: 
*

- The first line needs to be CACHE MANIFEST.

- The second line in this example is just a comment, but is useful to make changes to your web app by simply incrementing the version number. Note: Only changes to the manifest file will invalidate the cache.

- The third line begins the CACHE: section where you list out the asset files used by your web app, either relative to the location of the manifest file, an absolute path or complete URL. Note: DO NOT list app.appcache in your manifest.

- The NETWORK: section has a wildcard which permits the browser to download files that are not listed in the CACHE: section. Note: Without the NETWORK: section, the browser will ONLY re-request files listed in the CACHE: section after the initial page load.

2. Confirm Server Settings

You need to also make sure your web server serves the correct MIME type for the manifest file. For Apache, it looks like this:

AddType text/cache-manifest .appcache

You also need to makes sure the manifest file is not being cached on the server. If the HTTP Cache-Control header for the manifest file doesn't update, or a 304 Not Modified is return, then the web engine won't be able to see if the manifest file has been changed or not, which is the only way to invalidate the offline cache.

3. Add Manifest Attribute

You then need to add an attribute to the tag of every HTML page you serve pointing at the manifest file, like this:

<html manifest="app.appcache">

4. Add Update Script

Finally, you need to make sure your app updates itself if the manifest changes - the easiest way to do this is to add this bit of JavaScript to your main HTML:

<script>
window.applicationCache.addEventListener('updateready', function(e){
    window.location.reload();
});
</script>

5. Test

Your web app should now be offline enabled! If you have Python installed, you can test this by setting up a local server to see what's happening both on the server and in the browser.

beattier@amazon.com:~/html5demos/offline$ python -m SimpleHTTPServer

Serving HTTP on 0.0.0.0 port 8000 ...

1.0.0.127 - - [21/Jan/2014 13:42:52] "GET / HTTP/1.1" 200 -
1.0.0.127 - - [21/Jan/2014 13:42:52] "GET /app.appcache HTTP/1.1" 200 -
1.0.0.127 - - [21/Jan/2014 13:42:52] "GET /main.css HTTP/1.1" 200 -
1.0.0.127 - - [21/Jan/2014 13:42:52] "GET /main.js HTTP/1.1" 200 -
1.0.0.127 - - [21/Jan/2014 13:42:52] "GET /logo.png HTTP/1.1" 200 -

... 

If you request the page again, you'll see that *only* the manifest is requested.

1.0.0.127 - - [21/Jan/2014 13:43:12] "GET /app.appcache HTTP/1.1" 304 -

By modifying the manifest file and reloading, you'll see that all the files listed will be re-downloaded again.

You can also connect the Amazon Web App Tester to see the client side of the process as well by using Remote Debugging. (See our previous overview of setting up the Tester here.) In the screenshot above, I've connected to a Kindle Fire HDX and loaded a demo offline web app stored on Github. By looking at the Resources tab and drilling down into the Application Cache folder, I can see the assets that are cached locally, and a log of the Application Cache events.

Application Cache Gotchas

This is just a basic way to setup an offline web app. There are more options that you can add to your manifest file, more events you can track in JavaScript and more functionality you can use to make your web app's offline experience much more seamless to the end user. Check out the links below for more information.

Conceptually, it's important to understand that once you've enabled a manifest, your web app is now offline first and forever. Let's repeat that for clarity: OFFLINE FIRST AND FOREVER.

OFFLINE FIRST means:

- Your web app's files will then always be loaded from the offline cache first, and then a request will be made to the server for the manifest file to see if there have been any updates.

- The browser will not automatically refresh if the manifest has changed. It will in fact download the files from the server, but it will wait until the next time the page is requested to use them. This is why the script in step 4 above to detect a manifest change and immediately refresh the page is important.

FOREVER means:

- The only thing that can invalidate the offline cache and trigger a re-download of files is a change in the contents of the manifest file - not just the timestamp.

- There is no programmatic way to invalidate the offline cache from the browser. Even changing or deleting the manifest attribute in the tag will not invalidate the cache.

- Until the browser requests a manifest and receives a 404 or 410 from the server, it will continue to consider the web app as being offline and use the last downloaded version, rather than updating from the server.

Summary and External Resources

The info above should be able to get you started with offline web apps. Once you've added in the manifest, your web app will be available offline the next time your users load up your app. Fair warning: This can be a tricky feature to implement - especially if you misconfigure or forget some of the steps above. Getting the browser to let go of the manifest and refresh your code can be incredibly frustrating. I think the upside is worth it though, as enabling your web app to be used anywhere a native app can be used is incredibly satisfying.

To get more information about Application Cache, I encourage you to check out these great articles which dive into the topic in even more detail.

·         http://diveintohtml5.info/offline.html

·         http://www.html5rocks.com/en/tutorials/appcache/beginner/

·         http://www.html5rocks.com/en/mobile/workingoffthegrid/

·         http://alistapart.com/article/application-cache-is-a-douchebag

In future posts, I'll expand on offline apps by looking at topics such as offline data storage and efficient caching strategies.

-Russ (@RussB)

 

January 29, 2014

Mike Hines

Last week, I wrote to tell you about the new Dolby SDK that makes it easy for you to optimize the sound on the device to match the different kinds of audio you use in the course of your app. This week, we have some feedback from a developer who has implemented the Dolby Plug-In for their app on Kindle Fire.

Luxurious Animals is a game developer in New York. They wrote the casual game Lux Ahoy!, a netmagazine.com Top-10 game. Before working with Dolby Digital Pro, they didn’t consider audio to be a key component.  However after using the Dolby Plug-in, Luxurious Animals had this to say: “The API created a much richer and more immersive experience, making the game feel more exciting and absorbing.  It really took our game to the next level.”

Overall, Luxurious Animals found the Dolby Plug-in to be easy to work with and required no changes to the overall workflow:

“Adding the Dolby magic to our app was as easy as linking a JAR file with our project and calling Dolby-specific methods from our app. We used the Game audio profile inside the API, which creates a ‘live’ space to best bring out the effect of fast-moving objects in the audio. The API also offers Music, Movie and Voice profile options.  We had Dolby capabilities in the game up and running in less than 15 minutes. The API package comes with a Javadocs and a quick-start guide along with a sample application showing how Dolby APIs should be invoked.

Today, we have a fun casual game that not only has great-looking graphics, but also a rich soundtrack that pulls users in and holds their attention. We are confident these enhancements have increased the overall experience for our customers on the Kindle Fire HD.”

I’m thrilled that Luxurious Animals has been able to improve the customer experience for relatively little effort; it speaks well to the smart API design by the Dolby development team.  

To learn more about the Dolby Digital Plus SDK, please read the previous blog post on the topic here, or get the SDK directly from Dolby here.

 

January 22, 2014

Mike Hines

Note: Effective 08-26-2015 Free App of the Day (FAD) has been replaced with Amazon Underground.

Getting the right exposure for your app is a key ingredient to making it successful. Amazon already has several programs which developers can leverage to help drive visibility to their apps, and developers who want even more visibility think outside the box to tailor their customer experiences to increase engagement with their apps. Tribeplay is one of those game publishers who did just that, by issuing a price discount promotion that drastically increased their revenue.

The team which is based out of China has been building apps since 2012 and created the series of games under the title Dr. Panda that first appeared on iOS and Android. According to Tribeplay, making their Android Apps available on the Amazon Appstore required “little to no extra tweaking.” Tribeplay added that “one of the best things about the Amazon Appstore is that there wasn’t much work to get our apps on there. We already develop for Android, so getting our games on the Amazon Appstore was a real breeze.”

 

 

 

 

The games are available worldwide, but the team wanted to increase sales in Europe so they discounted the price of their apps by more than 50% in select countries. By doing so, Tribeplay saw their gross revenue more than double in UK, Germany, France, Italy, and Spain.

So how did the team accomplish this? Tribeplay ran banners highlighting their price promotion, which caught the attention of customers in the Amazon Appstore. When the Amazon Appstore recognized that their app was trending in customer popularity, Amazon assisted by providing more visibility for the app. “The suite of tools for promotions and sales [that Amazon provides] to help market our apps on the Amazon Appstore more effectively are very valuable.” said Tribeplay, the creators of Dr. Panda. The team saw the app’s sales more than double during the time period, when they increased the visibility of their app. 

Aside from the sales uplift, Dr. Panda was also able to reach a new and unique developer audience on Amazon. “Amazon Appstore is a fantastic platform for us and continues to get better. Through Amazon we’ve been able to reach a whole new demographic and really succeed with them. The fact that the Kindle Fire device line is so integrated to the store has also been a great benefit for both developing and marketing our apps with Amazon customers in mind.” The teams recently joined the Appstore Developer Select program and integrated the Mobile Ads API and are excited to see how the results will turn out. By participating in these programs, the team will receive additional impressions for their app, home page placements, and customized ads for their app in the US.

So how can you increase visibility? Besides having your app perform well, you can ensure your app qualifies for the Appstore Developer Select program, or get your app featured in the Free App of the Day program. If you’re looking for something similar to what Tribeplay did with their promotion, check out the Developer Promotions Console, which allows you to easily discount your apps. Getting your app onto these programs only requires a couple pre-requisites and they all aim at providing visibility for your app. For example, for your app to qualify for the Appstore Developer Select program, it must utilize relevant API’s such as Amazon In-App Purchasing, Amazon Mobile Ads, and Game Circle that all contribute to enhancing the user’s experience in your app. If you need help with these requirements we have a lot of resources available as well. “The Amazon team has always been amazing with their help and advice. Questions we ask are always answered promptly and accurately, and any problems we’ve had have been solved super quickly.” says Tribeplay.

 

January 17, 2014

Mike Hines

Dolby has just released a new Dolby Audio Plug-In for Kindle Fire HD and HDX that helps developers deliver even better audio to their users. Developers can now select an audio profile to optimize the sound based on the kind of audio being delivered. This means optimized audio setting for voice during your app’s dialog, and optimized settings for broad-range sound during your app’s action sequences. All with just a few lines of code you can insert into your app, no re-architecting required!

This isn’t the first time Amazon and Dolby have collaborated. Amazon and Dolby worked together on hardware and software enhancements for the Kindle Fire HD and HDX line of tablets for their launch, delivering Dolby Digital post-processing for native apps. But now Dolby has raised the bar again with Dolby Digital Plus, and the new Dolby Audio APIs for Kindle Fire. (Fear not, Unity fans. There is a Unity plug-in for you too.)

When you use the Dolby Audio Plug-in APIs, you can choose from four audio profiles to tune your sound profile to match the audio use in your app. For example, you can tune your app to use the Voice profile for dialog-heavy parts of your app, and the Game profile for first-person-shooter action. Here are the profiles you can choose from:

-Music: Applies equalization and dynamic range control to enrich instrumental and vocal quality in recorded music

-Movie: Clarifies the dialogue while providing the best representation of the full dynamic range of the program

-Game: Creates a ‘live’ space to best bring out the effect of fast-moving objects in the audio

-Voice: Customized for the reproduction of speech patterns and the tonal range of the human voice

This lets you deliver an optimized audio experience to your users, and it takes very little time to do so. Here are the high level steps to implement this API:

1.      Load the Dolby JAR file and import the DolbyAudioProcessing libraries

2.      Create a OnDolbyAudioProcessingEvent listener

3.      Call getDolbyAudioProcessing to get an instance of the Class (only done once for lifetime of the app)

4.      Wait for the app to connect to the DolbyAudioProcessing handler

5.      Instantiate the audio profiles as needed to in your app (Voice for dialog heavy parts, Game for FPS parts, etc…)

6.      Restore default audio behavior if your app is in the background

7.      Restore default audio behavior by releasing the Dolby instance on destroy

Setting the sound profile to use at different points in your app is pretty easy (see below).

    

You can set profile to Music, Movie, Game or Voice as appropriate at that location in your app.

Overall, integrating the API takes about an hour and does not require re-designing any logic or workflow. It’s a small investment for a big win.

You can download the free sample apk right away so you can hear for yourself how nice this is. To download the API, you need to sign up for a free developer account with Dolby (which took me less than 30 seconds).

Dolby has done a good job of making this easy to deploy. When you download the API package, you’ll get everything you need to get started, including javadocs, a quick start guide, and sample code showing exactly how to invoke Dolby APIs. You can download the free Dolby Audio Plug-in on this page, and learn more about Dolby Developer Services on their developer home page here.

 

October 17, 2013

David Isbitski

Excited about the new Kindle Fire tablets?  Can’t wait to get your hands on them to run your app?  We are happy to announce the emulators for Kindle Fire HDX 8.9”, Kindle Fire HDX 7” and Kindle Fire HD 7”.  For a smooth and quick experience to create and configure AVDs (Android Virtual Devices), we are also announcing the beta Amazon AVD Launcher.

Just how fast?

Via Abu Obeida Bakhach, Kindle Developer Programs Product Manager…

“Let’s be clear, Android emulators have a bad reputation. They are slow to start and use. Keeping that in mind, running the x86 system images with a capable GPU and the right virtualization options, you can run apps at near-device speed. But speed alone isn’t enough. We have built the third-generation emulators directly from Fire OS source code to provide the most accurate Kindle Fire emulation.

With Kindle Fire HDX sporting best-in-class hardware, providing true-to-device emulation requires a development machine with an equally solid graphics configuration. Both x86 and ARM system images take full advantage of the GPU. However, the optimal emulation experience is through x86 system images.

To demonstrate how much faster the x86 system images are than the ARM system images, we looked at the performance of Air Patriots, a game from Amazon Game Studios. This is a 74-MB APK that includes complex gameplay code along with a large set of assets. We ran the game on the Kindle Fire HDX 7” emulator, as well as on an actual Kindle Fire HDX 7” tablet.  We hosted the emulator on a Windows 7 machine with a quad-core 3.10 GHz processor, 8 GB of memory, and AMD/ATI Radeon R6570 graphics card.

The result? Fast startup and response time for the x86 system image. The gameplay was nearly identical to that of the tablet.” 

Here are the stats:
 


 

Getting Started

You should first set up the x86 system images for the Kindle Fire emulator as a faster alternative to ARM-based emulation, if your development computer running Windows or OS X has an Intel processor that supports virtualization extensions (VT-x). To determine the capabilities of your Intel processor, visit http://ark.intel.com/.

Typically, the better the overall processor performance, the better the emulator performance.  The performance of an x86 system image can be comparable to a physical Kindle Fire tablet when the emulator is running on a development computer that has a sufficiently capable processor and GPU. Using an x86 system image eliminates the translation of ARM to x86 instructions that occurs at runtime when using the ARM-based emulator.

You can read the full documentation on Setting up Intel® Hardware Accelerated Execution Manager (Intel® HAXM) here.

If you have any issues downloading through the Android SDK Manager here is a direct link I have found helpful in my own installations.

I am using a Macbook Air for this blog post but all of the Intel HAXM drivers and Android AVD work just as well on Windows.
 




Once you have the HAXM drivers successfully installed you will need to make sure you check of Intel x86 support for each API Level/Kindle revision you want to use.  This is done through the Android SDK Manager like you would for any other Android Emulator image.

 


 

You will know that the x86 hardware emulation is successfully running when you first start one of the new emulators as seen below.
 


 

Choosing the correct Kindle Fire Images in the Android SDK Manager

Once you have the Intel HAXM driver installed and working correctly you will need to download the Kindle Fire Images from the Android SDK Manager by following the directions in the Setting Up Your Development Environment faq.

Be sure to select the appropriate Kindle generation under the corresponding Android API Level.  For example, the new Kindle Fire HDX’s are the third generation of Kindle Fire devices and support Level 17 of the Android API.

Android 4.2.2 API 17:

  • SDK Platform
  • ARM EABI v7a System Image (emulator prerequisite for ARM system images)
  • Intel x86 Atom System Image (emulator prerequisite for x86 system images)
  • Kindle Fire HD 7" (3rd Generation) (ARM and x86 system images for emulator)
  • Kindle Fire HDX 7" (3rd Generation) (ARM and x86 system images for emulator)
  • Kindle Fire HDX 8.9" (3rd Generation) (ARM and x86 system images for emulator)

Also, do not forget the Extras section as I have seen some developers miss the Kindle Device definitions specifically, which will result in blank entries in the Amazon AVD Launcher.

  • Extras:
    • Kindle Fire Device Definitions
    • Kindle Fire USB Driver (not applicable for OS X)
    • Android Support Library
    • Intel x86 Emulator Accelerator (HAXM) (emulator prerequisite for x86 system images)
    • Amazon AVD Launcher

Running the new Amazon AVD Launcher

Now that we have full Intel x86 image support and working Kindle Fire Images form the Android SDK we need to set up the Amazon AVD Launcher.  You can read the installation faq here for step by step instructions.

The Amazon AVD Launcher tool simplifies the process of creating an Android Virtual Device (AVD) by allowing you to select the device you want to emulate and automatically filling in the correct settings.  As a result, the Amazon AVD Launcher is a more reliable way of configuring the emulator than manually configuring it with the Android AVD Manager.

You will find the new Amazon AVD Launcher executable in the Android sdk/extras/Amazon/ folder of your local Android SDK installation.  Upon running it for the first time you will be treated to a graphical list of all the Kindle Fire Images you have installed and their associated specs as seen below.
 


 

Click the Create AVD button or switch over to the Amazon AVD tab and select New to create a new image.  You will notice the options are much more streamlined now and selecting the appropriate Kindle Fire image will automatically set all of the options for you.  No more guess work!
 


 

You can name the new AVD image whatever you chose.  Make sure that you have the Intel x86 image support selected and that Host GPU is clicked.
 


 

I also recommend clicking on the Advanced Options tab and selecting both My Computer Keyboard for Keyboard and Webcam (Webcam0 for my Macbook Air as seen in the screenshot) for the front camera.  This will be sure to use your computer’s keyboard instead of software emulation as well as its webcam
 

 

You can leave all of the Memory settings at the default levels they have already been set to the most optimized for the image automatically.  You can then start the image by clicking the Start button in the Amazon AVD Launcher and will be greeted with a couple of launch options, mostly associated with how you want to fit the emulator on your screen and the ability to wipe the virtual machine’s data.
 


 

Congratulations, you now have a fully functional Kindle Fire image running at hardware-virtualized speeds!
 


 

Do not forget if you are using an existing code base to change your target emulator from your previous AVD to the new Amazon AVD image you have created as seen below.
 


 

Conclusion

We found that 80% of developers ran into trouble using the Android Virtual Device Manager to create, configure and launch AVDs.  Instead of fiddling with build targets, guessing API levels, RAM and other settings, we know you want to instantly create and launch an emulator and just focus on developing and testing your app.

At Amazon, we believe that granting developers a choice of tools ensures a more flexible and productive mobile development experience. By preserving the Android definition of an AVD, the Amazon AVD Launcher is fully compatible with the Android Virtual Device Manager, allowing Kindle Fire AVDs created by either tool to be launched on the other.

Warning: Once we loaded games on emulators with the right GPU emulation and x86 system images, we had problems pulling away testers hooked on playing at device-like speed!

Please provide feedback at kindle-sdk-beta@amazon.com or the Kindle Development Tools forum.

 

-Dave (@TheDaveDev)

 

August 14, 2013

Mike Hines

We’ve gotten a few questions recently about Adobe AIR support on Kindle Fire. Here is the quick FAQ:

Do Kindle Fire devices have Adobe AIR embedded?

Yes.

The Original Kindle Fire has Adobe AIR 2.7.1 embedded as a Shared Runtime. The Kindle Fire, Kindle Fire 7” HD, and the Kindle Fire 8.9” HD devices (the Kindle Fire devices running ICS) all have Shared Runtime support for Adobe AIR 3.1.

Can I use a newer version of AIR for my app?

Yes.

The current version of Flash Builder includes support for Captive Runtime, a way that you can package the most recent version of Adobe Air with your app. Everything you app needs to run is packaged directly into the apk. Note: The ADT –package command is now packaging AIR 3.7 and higher as a Captive Runtime by default. See this note from Adobe for more details.

Does Kindle Fire have any Adobe AIR Native Extensions (ANEs)?

Yes.

We have two free Adobe AIR Native Extensions for the Kindle Fire. One for In-App Purchasing, and another for GameCircle integration. You can read the press release here.

 

August 08, 2013

Peter Heinrich

Mobile app and game developers are no strangers to working in the cloud, which is why Amazon has added a dedicated Mobile and Gaming Track to its AWS re:Invent conference this year. Held November 12-15 in Las Vegas, AWS re:Invent will offer dedicated sessions and a special bootcamp tailored to mobile app and game developers like you. Register early as the conference sold out last year!

Deep dive technical sessions and hands-on labs will teach you how to scale your mobile app or game on the AWS cloud, distribute on Amazon, reach millions, increase user engagement and monetization, and more. You’ll also have the opportunity to meet Amazon teams in person, get one-on-one support, and attend a special reception.

Technical sessions during the main conference will focus on AWS features and services that speed mobile development and increase your audience. You’ll also learn how to get the most from Kindle Fire hardware without sacrificing compatibility on other mobile devices. Developer case studies will explain the tips and tricks they used to successfully monetize their apps and games. Here’s a sample of sessions to be offered:

A pre-conference bootcamp will dive even deeper, with a full day of intensive instruction and live coding with the Amazon APIs, including GameCircle, A/B Testing, In-App Purchasing, and Mobile Ads. Starting with design patterns common to Games-as-a-Service and deployment to AWS, this workshop will move on to the specifics of implementation, publishing on the Amazon Appstore, and how to market your application or game on Amazon.com and Kindle Fire devices.

Join us in Las Vegas this November for the dedicated Mobile and Gaming track at AWS re:Invent 2013.

 

August 06, 2013

Mike Hines

Starting today, you can submit your web apps and mobile optimized web sites and have them merchandised alongside native apps on Amazon and Kindle Fire in nearly 200 countries worldwide, without any third-party software or doing any native app development. Amazon Web App Resources (http://developer.amazon.com/webapps) provides the tools that you need to optimize your web apps for Kindle Fire and Android devices to sell them in our store, including powerful tools to help you test and debug your web apps and monetize using Amazon’s In-App Purchasing API for JavaScript. Plus, we’ve made sure your web apps achieve native-like performance on Kindle Fire with our new fast web runtime, based on the Chromium engine.

Rialto

Tools

To make sure your web app works great on Kindle Fire and Android devices, you can use the Web App Tester, which you can get from our store here. The Web App Tester allows you to test your web app in a production-like environment before submitting it to Amazon, and offers a suite of tools to help with on-device debugging of your web apps, ensuring that they’ll work great on Android and Kindle Fire.

We’ve also created and made available the Amazon In-App Purchasing API for JavaScript, allowing you to easily build sales of digital goods like gems, level unlocks, and subscriptions into your web apps.

Kindle Fire web runtime

Kindle Fire’s web runtime is based on the open source Chromium project, and is GPU-accelerated and optimized for fluidity to make sure your web apps run smooth on Kindle Fire, just like a native app. The new runtime supports the latest HTML5/web features and includes standards-based extensions that give you access to offline storage and location sensors. Read more about the updated web app runtime here.

Get started today

Web developers with HTML5 apps and mobile-optimized web sites can easily get started at the Amazon Mobile App Distribution Portal. Once you’re logged in, go to “My Apps”, hover over the green “Add New App” button and click “Add new Web App”.  More information on how to prepare and submit your web apps is available here.

July 24, 2013

Peter Heinrich

Amazon Mobile Ads

Today, we announced the general availability of the Amazon Mobile Ads API which gives you the ability to earn great eCPM by monetizing your app with mobile ads from the Amazon Mobile Ad Network.                                                     

eCPM is the amount you earn for each 1,000 ads you display in your app. Higher values are obviously better, and we’ve seen the average eCPM for the Amazon Mobile Ad Network rise 30% since its beta launch in March.  Early adopters like Games2Win have already discovered our great monetization solution for banner ads.

‘The $2.00 eCPM we saw from Amazon far exceeded our expectation. We tested Amazon in our Kindle app first. Now we’re racing to get the Amazon ads integrated in all of our apps across all Android stores.’ says Mahesh Khambadkone, Co-Founder of Games2Win.

Starting today, the Amazon Mobile Ads API will be included as part of our Amazon Mobile App SDK. Developers who integrate the Amazon Mobile Ads API into apps they offer through Amazon may also distribute these apps using the API through any other Android platform.

To provide extra incentive to incorporate the Amazon Mobile Ads API into your apps (as if great monetization and ease of use weren’t enough), Amazon is offering a free Kindle Fire HD to developers who integrate our API in the next few weeks. All you have to do is submit your API-enabled app between July 25th and September 1st and send at least 500 ad requests to the Amazon Mobile Ad Network every week between September 15th and October 19th. (See terms and conditions below.)

We’re excited to share the success of the Amazon Mobile Ads API and encourage you to consider including the API in your next application. For more information, see the online documentation or our quick start guide.

 

Terms and Conditions of Kindle Fire HD Offer:

  • To qualify for a free Kindle Fire HD, 7” display, 16 GB, with special offers, app developers must meet all of the terms and conditions of this offer.
  • This offer begins at 12:01 a.m. (PT) September 15th, 2013 and ends at 11:59 p.m. (PT) October 19th, 2013 (the “Offer Period”). 
  • A “Qualifying App” is any mobile app that has integrated the Amazon Mobile Ads API and is submitted to the Amazon Mobile App Distribution Portal between and including July 25th and September 1st, 2013. Apps that have sent ad requests to Amazon using the Amazon Mobile Ads API prior to July 25, 2013 are not Qualifying Apps.
  • A developer’s Qualifying Apps must send at least 500 ad requests every week during the Offer Period.  (Each week begins at 12:01a Sunday and ends at 11:59p Saturday.)  This offer is only open to developers who send the required number of ad requests for the entire Offer Period.
  • A developer may use a single Qualifying App or multiple Qualifying Apps to generate the 500 weekly ad requests as long as the Qualifying Apps are registered to a single developer account.
  • Limit one free Kindle Fire HD device per developer.
  • Offer good while supplies last.
  • Qualifying Apps must meet the Mobile Ad Network Program Participation Requirements.
  • Developers must agree and adhere to the Program Materials License Agreement and the Mobile Ad Network Publisher Agreement to qualify for this offer.
  • Qualifying developers must be reachable through the email addresses registered on the Distribution Portal.
  • Amazon will attempt to ship the Kindle Fire HD device to qualifying developers in the U.S. and other countries.  However, Amazon is not responsible for customs or taxes required for international deliveries.
  • Amazon reserves the right to modify or cancel this offer at any time in its discretion.
  • This offer is void where prohibited.

 

July 23, 2013

Peter Heinrich

Save game data in the cloud to protect your customers’ progress and support play from multiple devices

In just a few short years, the explosion in popularity of smart phones and tablets has transformed gaming, as touch controls, geolocation, and micropayments enter the mainstream. Online storage is also becoming more common, as developers adjust to a major challenge of mobile devices: physical durability. Keeping your data in the cloud starts to look mighty attractive compared to keeping it on a device that’s easily misplaced, damaged, or stolen.

Blob storage is a common way to save data online (game data is simply written to the cloud as one big chunk). If two devices update the same data, though, one of the updates must be ignored or overwrite the other. You have to decide which update to keep (based on a timestamp or version number, perhaps), or maybe prompt the user to choose between them. Either way, data is lost.

Because of the overhead involved, many developers don’t even bother with this naïve approach. This is a huge disservice to the player, whose game progress is completely lost if anything happens to his or her mobile device. Whispersync for Games saves game data for you, and works across all Android devices (including Kindle Fire).

Mergeable and Non-mergeable Data

Whispersync was designed to prevent data loss, make developer or player intervention unnecessary when resolving conflicts, and be dead-simple to integrate and use. It doesn’t distinguish between online and local storage, so the programmer doesn’t have to handle separate cases for saving to disk and cloud. It does this by manipulating only mergeable data.

Game data is mergeable if a simple rule can be defined to resolve conflicting values. For example, the rule associated with the best completion time might be, “Take whichever value is smallest.” To keep track of a player’s best score, we might use, “Take whichever value is highest.” In some cases, the most recent value may be the most important, so the appropriate rule would be, “Take whichever value is newest.” These rules apply at a granular level; Whispersync doesn’t treat game data as one big chunk.

Not all game data can be resolved using simple rules, though, in which case we call it non-mergeable. The current state of a chess board, for example, requires a complex tree structure to describe it. Reconciling two versions of the board is more complicated than just choosing the “lowest” or “highest” one.

Describing Game Data Using Syncable Types

Fortunately, a lot of game data is naturally mergeable or can be adjusted to be so. Whispersync offers many different syncable types with several built-in rules to resolve conflicts. They can be used to model simple and complex game data.

  • SyncableNumber – A number that is the lowest, highest, or most recent.
  • SyncableString – A string that is the most recent.
  • SyncableAccumulatingNumber – A number that can be incremented and decremented.
  • SyncableNumberList – A list of numbers in ascending, descending, or latest order.
  • SyncableStringList – A list of strings ordered by most recent.
  • SyncableStringSet – A set of strings.
  • GameDataMap – A nested map, allowing hierarchical data.

A global GameDataMap object represents the root storage for your game, storing named values of the types above. Setting a value that doesn’t exist will create it on the fly. The accessor used to retrieve a value determines the conflict resolution strategy that will be associated with it.

  public static final String SKILLS = "skills";
  public static final String TOTAL_TIME = "totalTime";

  public static final String LEVEL_MAP = "levelMap";

  public static final int NUM_LEVELS = 5;
  public static final int MAX_ITEMS = 3;

  public static final String SCORE = "score";
  public static final String STARS = "stars";
  public static final String BEST_SCORES = "bestScores";
  public static final String BEST_TIMES = "bestTimes";

  GameDataMap gameDataMap;

  public void initGameData() {
    gameDataMap = AmazonGamesClient.getWhispersyncClient().getGameData();

    // These will be independent of level.
    gameDataMap.getStringSet(SKILLS);
    gameDataMap.getAccumulatingNumber(TOTAL_TIME);

    // Use nested maps to establish some per-level values.
    for (int i=0; i < NUM_LEVELS; i++) {
      GameDataMap levelMap = gameDataMap.getMap(LEVEL_MAP + i);

      // Each level will have its own copy of these values.
      levelMap.getLatestNumber(SCORE);
      levelMap.getHighestNumber(STARS);
      levelMap.getHighNumberList(BEST_SCORES).setMaxSize(MAX_ITEMS);
      levelMap.getLowNumberList(BEST_TIMES).setMaxSize(MAX_ITEMS);
    }
  }

In the example above, we use initGameData() to establish the structure of the data we’ll synchronize, even though we don’t actually set any values. (It can be helpful to define the data layout in one place like this, even if it’s not strictly required.) The code effectively says,

  • There will be a global set of strings called SKILLS. It will track every string added to it (strings may not be removed).
  • There will be a global running total of time in the game called TOTAL_TIME. It will accumulate deltas submitted from all devices used by a single player.
  • There will be NUM_LEVELS nested maps, each of which will have its own set of values:
    • SCORE will always reflect the last score submitted for that level.
    • STARS will always reflect the maximum stars attained for that level.
    • BEST_SCORES will always list the MAX_ITEMS highest scores for that level.
    • BEST_TIMES will always list the MAX_ITEMS fastest times for that level.

Updating and Retrieving Game Data

Whispersync abstracts all game data persistence, so we can update or retrieve values using simple getters and setters. We don’t have to worry about managing a network connection, saving to disk or the cloud, or reconciling local and online versions of variables we have in memory. When we add to the running total of time played, for example, Whispersync automatically saves the delta to disk and updates the cloud if connected. If the player’s device is currently offline, the update will be queued and delivered later.

  public void updateTotalTime(int timePlayed) {
    SyncableAccumulatingNumber totalTime = gameDataMap.getAccumulatingNumber(TOTAL_TIME);

    // Add the time played to the running total.
    totalTime.increment(timePlayed);

    // Output the new total to the console.
    System.out.println("Total Time Played = " + totalTime.asInt());
  }

Likewise, we can record skills as the player masters them and easily iterate over the set to display the ones learned so far:

  public void learnSkill(String skill) {
    SyncableStringSet skillSet = gameDataMap.getStringSet(SKILLS);

    // Add the new skill to the player's repertoire. Note that this list

    // can only expand; strings cannot be removed.
    skillSet.add(skill);

    // Output all skills to the console.
    for (SyncableStringElement s : skillSet.getValues()) {
      System.out.println("Skill = " + s.getValue());
    }
  }

Updating numbers and number lists is just as straightforward, so persisting all of the player’s progress at the completion of a level can be done in just a few lines:

  public void finishLevel(int level, int score, int stars, int time) {
    GameDataMap levelMap = gameDataMap.getMap(LEVEL_MAP + level);

    // Save the score for this level. Newer values will always overwrite
    // previous scores.

    levelMap.getLatestNumber(SCORE).set(score);

    // Try to set the new maximum stars attained on this level. If the
    // value is less than the current maximum, this call does nothing.

    levelMap.getHighestNumber(STARS).set(stars);

    // Try to add this score to the list of all-time bests. If it's not
    // high enough, this update will be ignored.

    levelMap.getHighNumberList(BEST_SCORES).add(score);

    // Try to add this completion time to the list of all-time bests. If
    // it's not low enough, this update will be ignored.

    levelMap.getLowNumberList(BEST_TIMES).add(time);
    updateTotalTime(time);
  }

The accessors on GameDataMap and Whispersync’s syncable types make it easy to manipulate game data and define how conflicts should be resolved.

Think Mergeable!

Whispersync for Games automatically resolves conflicts for data it can merge, which makes it worthwhile to describe game data using syncable types when possible. Since Whispersync supports high, low, and most recent numbers and number lists; running totals; latest strings and string lists; sets of strings; and nested maps supporting hierarchical structures, a wide range of game data can be modeled.

Thinking about your game data in mergeable terms lets you push a lot of overhead out of your code. Let Whispersync handle the heavy lifting. For more information on integrating Whispersync into your game, see the online documentation

 

July 04, 2013

Peter Heinrich

Continuing our series of success stories from developers around the world, we go to France, where developers are witnessing strong positive results less than a year after the launch of the Amazon Mobile App Distribution Program in August 2012.

Ubisoft’s PC and console titles have been available on Amazon for a long time, helping to build a great partnership between both companies over the years. As Ubisoft strengthened its mobile offering, it was a natural progression for their Android games to be made available on Amazon and to Kindle Fire users. Dominique Tardieu, Sales and Marketing Director at Ubisoft Mobile, explains: “Amazon and Kindle Fire tablets hold a significant potential for our mobile games as they become more and more widespread. Also, Amazon has developed a meaningful ecosystem for Kindle Fire games via Amazon GameCircle. This gives us the possibility to leverage the social aspects of our games, through Player vs Player functionality and leaderboards, for instance.”

Since September 2012, Ubisoft has successfully launched a variety of best-selling games on Amazon, including Rayman Jungle Run, Prince of Persia, and (more recently) Nutty Fluffies. An important element of these games’ success so far has been Amazon personalization and recommendations. Tardieu says, “The experience they bring in terms of customer relationship management and knowledge of the industry has made it possible for us to ensure a successful launch for all our titles. Amazon clearly benefits from the know-how acquired over the years working on Ubisoft’s console and PC games and has learned how to harness it to successfully promote the right content to the right consumers.”

About Ubisoft:
Ubisoft is a leading producer, publisher, and distributor of interactive entertainment products worldwide and has grown considerably through a strong and diversified line-up of products and partnerships. Ubisoft has offices in 26 countries and operates in more than 55 countries around the globe. It is committed to delivering high-quality, cutting-edge video game titles to consumers. For the 2011-12 fiscal year, Ubisoft generated sales exceeding €1 billion. To learn more, please visit: www.ubisoftgroup.com

 

July 03, 2013

Peter Heinrich

Following up on the first in a series of webinars covering Amazon devices, game services, and mobile applications, here’s a list of questions we collected during and after our presentation on Amazon Device Compatibility and Optimization.

Is it possible to test the compatibility of my existing android app with an emulator?

Yes, you can and should use the Kindle Fire emulators to test compatibility of your Android app. The Kindle Fire emulator consists of:

  • The Android emulator, which is part of the Android SDK.
  • Android Virtual Devices (AVDs).
  • Kindle Fire system images.

The Kindle Fire system images provide the additional code needed to emulate Kindle Fire tablets.

Note: We provide ARM and x86 system images for the Kindle Fire emulator as SDK add-ons. If your development computer can run the x86 system images, which are available for all tablets except Kindle Fire (1st Generation), you should use them for faster emulation. For more information, see Understanding the Kindle Fire Emulator.

How does DRM and license validation work in the Amazon store? Can we verify it’s working once the app is live?

When submitting your app, on the Binary Files tab, developers can choose Apply Amazon DRM? If selected, only customers who have purchased the app may use it. If not, your app may be used by anyone without restrictions. To test this once the app is live, sign in to the Amazon store with a different user account (or simply sign out of the Amazon store client) and try to open the app on the device. If DRM is active, your app is protected and an error will be reported.

What versions of Adobe AIR are available? When will new AIR versions become available?

The original Kindle Fire runs Gingerbread and therefore ships with AIR 2.7. The second generation Kindle Fire, including all Kindle Fire HD devices, run IceCreamSandwich and ship with AIR 3.1. Developers that need newer versions of AIR 3 in their apps can do so by leveraging captive runtime.

Is there a low-tech solution to creating a screen-size that will work for Kindle Fire and Kindle Fire HD, like 600x600?

Please see Screen Layout and Resolution for information on designing for the different Kindle Fire screen. The simplest option would be to test each layout on the Kindle Fire emulators to confirm and tweak them as necessary. See Running the Kindle Fire Emulator for more information.

When you say unsigned apk, is that the same as not exporting the apk in Eclipse?

Yes. That is correct. We are referring to an apk not built for release.

Is there a rule, or recommendation about package names in different App Stores? Can they be the same?

Yes, they can be the same.

Can I apply a signature to my app?

All applications must be digitally signed with a certificate. The default signature applied to your app is a certificate supplied by Amazon that is unique to your developer account. If your signing strategy requires that a different certificate be applied, you may do so by submitting a request using the Contact Us form. Please indicate the title of the app for which you are submitting the request.

Is the certificate different from .keystore?

Yes. The type of certificate used by Amazon to sign a developer's application is the same type generated by standard tools like keytool or jarsigner.

 

Don’t miss out next webinar event: Integrating GameCirle in Your Games on July 25th, 2013 @ 10:00 AM.

Pre-register here!

June 30, 2013

Peter Heinrich

We just released a major update to Amazon GameCircle, our free game service providing achievements, leaderboards, and Whispersync for Games. Games on all Android devices (including Kindle Fire, of course) can now integrate GameCircle, which is easy because we support Java, JNI, and Unity3D. Whether you submit your game to Amazon or Google, customers will benefit from the GameCircle experience. In addition, Whispersync has been dramatically improved, becoming the first and only cloud-save service to:

1) Automatically resolve data conflicts between mobile devices and the cloud,

2) Queue updates to support offline operation, and

3) Offer a simple interface that can be integrated in minutes.

The result: Your customers’ game data will automatically sync across devices—even if they play your game while temporarily offline—and you can concentrate on using the data instead of persisting it. You’re not locked in, though; you retain ownership and can always get a copy of the data you store.

We also give you flexibility when it comes to GameCircle display options, with no intrusive splash screen and configurable notification toasts. You’re in control and choose where they appear.

I’ll provide more technical details about these enhancements in future posts, but for now, let’s take a closer look Whispersync and explore its powerful new features and simplified interface.

Whispersync for Games

Whispersync does the heavy lifting when it comes to synchronizing local data to and from the cloud. It handles the tricky scenarios that you would normally have to deal with yourself, like conflicting updates from multiple devices or sync requests from a device that’s temporarily offline. You can also stop worrying about scalability; behind the curtain, Whispersync (and all of GameCircle) is powered by Amazon Web Services like S3 and DynamoDB.

Using Whispersync is easy through an API that has been completely redesigned, providing an interface similar to SharedPreferences. Saving game data to the cloud and synchronizing it between devices is as easy as retrieving a variable from a map and using (or changing) its value:

    // Get the global game data map for the current player.
    GameDataMap gameDataMap = AmazonGamesClient.getWhispersyncClient().getGameData();

    // Look up the object representing the player’s skill rating.
    // If none exists, one will be created.

    SyncableNumber skillRating = gameDataMap.getHighestNumber("skillRating");
    System.out.println("skillRating = " + skillRating.asLong());

    . . .

    // Update the value. As long as this device is online (or as soon as
    // it is), local and cloud storage will be synced.

    skillRating.set(MAX_SKILLRATING);

Whispersync maintains a singleton instance of GameDataMap that acts as the root of your game data. It can track numbers, strings, simple lists, and other maps, and gives you complete freedom in how you represent your game data using these basic syncable types. You add new variables simply by retrieving them by name; if they don’t exist, they’ll be created on the fly and synchronized from that point on.

How Whispersync applies updates and resolves conflicts depends on the way you access each syncable variable. For example, suppose you want to retrieve the current user’s best (highest) level across all devices:

    GameDataMap gameDataMap = AmazonGamesClient.getWhispersyncClient().getGameData();
    SyncableNumber bestLevel = gameDataMap.getHighestNumber( "bestLevel" );
    System.out.println( "bestLevel = "  + bestLevel.asLong());

In this case, because “bestLevel” is retrieved as a highest number, it will always reflect the maximum value ever assigned to it, from anywhere, on any device.

String values can also be synced. You could easily set the name of the latest power-up collected:

    gameDataMap.getLatestString( "lastPowerUp" ).set("Super Boingo"); 

The syncable string associated with “lastPowerUp” will always reflect the value most recently assigned to it.

The online documentation and Javadoc included with the SDK have more information on the syncable types Whispersync supports, as well as the ways in which each may be accessed.

Practical Applications

Let me provide a few more examples to illustrate just how straightforward synchronization can be.

Recording Star Count for Several Levels

A common pattern in many games is to show stars and unlock status for each level on a level selection screen. Here’s an example of using Whispersync to track individual star values for multiple levels:

  SyncableNumber[] getLevelStars() {
     GameDataMap gameDataMap = AmazonGamesClient.getWhispersyncClient().getGameData();
     SyncableNumber[] stars = new SyncableNumber[NUM_LEVELS];

     // Get the star counts for all levels.
    
for (int i = 0; i < stars.length; i++) {
        stars[i] = gameDataMap.getHighestNumber("levelStars" + i);
     }

     return stars;
  }

The first time the score values are accessed (from anywhere), Whispersync will create entries for them in the cloud, so there’s no need to declare them ahead of time.

Accumulating a Running Total

Some progress, like coins collected or time played, represents a running total that is always updated using a delta amount. Instead of setting the value directly, you just submit the amount by which it should change. Whispersync automatically adds or subtracts this value to update the current total. For example:

 void addTimePlayedToTotal(long timePlayed) {
    GameDataMap gameDataMap = AmazonGamesClient.getWhispersyncClient().getGameData();
    SyncableAccumulatingNumber totalTime =        gameDataMap.getAccumulatingNumber("totalTime");

    // This object may be incremented/decremented with long, double, and
    // BigDecimal values.

    totalTime.increment(timePlayed);
    System.out.println("Total time played: " + totalTime.asLong());
 }

Keeping a Map of Maps

By embedding a map within a map, you can create a hierarchical data structure. If your game has multiple worlds, for example, you might keep a separate GameDataMap for each one. Each of these might contain additional maps—say, one for each level.

 GameDataMap getWorldData(String name) {
    GameDataMap gameDataMap = AmazonGamesClient.getWhispersyncClient().getGameData();

    // Get all the string keys associated with top-level GameDataMap objects.
    Set<String> worldNames = gameDataMap.getMapKeys();

    // Look for a match among the maps.
    for (String currentName : worldNames) {
       if (currentName.equals(name)) {
          // A map exists for the name specified.
          return gameDataMap.getMap(currentName);
       }
    }

    // No match found. Don't create one.
    return null;
 }

Maintaining a List of Numbers

A racing game might save a player’s top three best times using a syncable number list. In this case, you could create a list for low numbers—they decrease as times improve—but you could easily choose to retain a collection of the highest or most recent values in other situations.

 // We'll initialize this once the application has launched.
 AmazonGames agsGameClient;
 GameDataMap agsGameData;
 SyncableNumberList agsBestTimes;

 // Create a callback to handle initialization result codes.
 AmazonGamesCallback agsGameCallback = new AmazonGamesCallback() {
    @Override
    public void onServiceReady(AmazonGamesClient client) {
       agsGameClient = client;
       agsGameData = AmazonGamesClient.getWhispersyncClient().getGameData();

       // Establish how many slots will be allocated and preserved.
       agsBestTimes = agsGameData.getLowNumberList("bestTimes");
       agsBestTimes.setMaxSize(3);
    }

    . . .
 };

  void finishLap(double time) {
   // Every time a lap is completed, try to add the lap time
   // to our list of best times. Only the lowest three will
   // ever be preserved.

   agsBestTimes.add(time);
 }

Every time the player finishes a lap, finishLap() would be called to update the number list. The value specified will be discarded unless it is lower than one of the current entries.

More to Come

The GameCircle improvements released in the latest update deserve more attention than the brief overview I’ve given here, so I’ll add details in the coming weeks. Look for articles dedicated to JNI; advanced API features; and using GameCircle with frameworks such as Unity3D, Cocos2d-x, and Marmalade. I’ll also dive deeper into Whispersync, discussing the difference between mergeable and non-mergeable data (and why it’s important), considerations when synchronizing currency across offline devices, and migration from the previous version. Stay tuned!

In the meantime, check out the new GameCircle release and give it a whirl. You’ll benefit whether you use the simplified Whispersync API and its expanded functionality, create a universal build to run on Kindle Fire and Android, or take advantage of the other features included with this update.

Want the latest?

appstore topics

Recent Posts

Archive