MobileHow to Prep Your Android Apps for Kindle Fire

How to Prep Your Android Apps for Kindle Fire

Developer.com content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More.

This article was re-printed with permission from Amazon Digital Services, Inc.

Amazon recently introduced two new HD tablets: the Kindle Fire HD 7” and Kindle Fire HD 8.9″. While most developers have had few problems transitioning apps from phone layouts and hardware to run well on the Kindle Fire HD tablets, customer feedback, as well as Amazon’s own Quality Assurance reviews, has identified a few development tips you can use to deliver a great experience on the new HD tablets.

Plan for the Screen Layout

Customers love the larger format of the tablets. That’s why it’s important to make sure your app is designed for high-density screens with correctly sized images, and fill the screen size by using appropriate layouts (e.g., res/layout-sw800dp for the Kindle Fire HD 8.9″and res/layout-sw533dp for the Kindle Fire HD resource directories). Appropriate use of the screen is especially important for apps that want to use the HD designation. Make sure to check out the documentation we provide on optimizing for high-density screens on the Mobile App Distribution Portal as well as on the blog.

Get the Amazon SDK

Display the Right Assets

For your apps to support multiple devices, you will want to make sure to display the right assets in the right place. If your app will be downloading additional resources based on the platform, it’s important to make sure you are selecting the correct assets for the device. The best way to future-proof your app is usually to use feature detection or resolution detection, but as a fallback option you can use device user-agent or Build.MODEL strings. If you are relying on device strings, we recommend managing that list on a server, so you can easily add new devices or update existing ones. If instead you hard-code the strings, you’ll have to deploy a new .apk each time you wish to update or add a new string. You can find the Kindle Fire android.os.Build.MODELand user-agent strings in our Device and Feature Specifications.

Sensor-Based Orientation

Every Android tablet defines top of the screen differently. On the Kindle Fire HD tablets, the default rotation is in landscape mode with the camera at the top (ROTATION_270), whereas landscape might be the opposite (ROTATION_90) for other devices. If your app is designed to work in landscape mode, then we recommend that you use sensor-based orientation rather than relying upon the rotation value, e.g. setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);

Manage Memory Use

With the larger screen sizes of HD devices, efficient memory management becomes even more crucial for your app, as more memory is required for displaying larger bitmaps.

In your app, ActivityManager.GetMemoryClass();returns the heap size and will help you understand how aggressive you need to be in memory management. The default application heap size is 48MB for Kindle Fire HD 7” and 64MB for Kindle Fire HD 8.9”. If your app attempts to exceed the default heap size, you will receive an OutOfMemoryException. The best way to understand how memory usage is affecting your app’s performance is by using Logcat, via DDMS or the command line, to examine the logs for Garbage Collection events and analyzing heap usage and memory allocation. The Dalvik Garbage Collection logging statement contains a lot of information that will help determine if your app has potential problems such as high memory usage or potential memory leaks. For an overview of how to use DDMS and MAT to analyze memory issues, we recommend reading Memory Analysis for Android Applications.

GC_CONCURRENTfreed 380K, 17% free 16204K/19335K, paused 1ms+2ms

The first statement describes why the Garbage Collection action was performed. It can have the following values:

  • GC_CONCURRENT – called when heap isfilling up to prevent a expensive GC_FOR_MALLOC call.
  • GC_FOR_MALLOC – called when the heap isfull. The application is paused during collection.
  • GC_HPROF_DUMP_HEAP – Indicates a HPROFfile has been created.
  • GC_EXPLICIT – Indicates an apprequested Garbage collection by calling System.gc()

It is normal to see a healthy amount of GC_CONCURRENT log statements as your app is running. However, watch for large amounts of GC_CONCURRENT calls in areas where response time is critical. A consistent GC_FOR_MALLOC could indicate that your app is close to the edge of its memory constraints.

The logging statement also indicates how much memory was freed, how much of the heap is currently free, and how long Garbage Collector had to pause the app to complete its work.

Android also provides a way to expand your maximum heap size by adding android:largeHeap=”true” to your app’s manifest. This will increase your maximum heap size to 256MB. However, this is not silver bullet solution. A larger heap size means longer pauses for GarbageCollection and a degraded overall user experience as background apps are trimmed to free up memory. The performance hit is not trivial, so only use when necessary and for apps that don’t rely on a real-time user response, such as a fast-paced game.

Test Your App (Before We Do)

Our QA teams run a number of tests to make sure apps will run as expected on the Kindle Fire HD tablets. For example, we run an automated analysis of the manifest and app. We also do in-depth usage and “stress testing” to try and identify issues before our users might see a problem. Our testing, however, can’t identify every possible issue, so the more testing and optimizing you can do before you submit your app, the better experience your users will have. Make sure to follow our pre-submission testing guidelines before submitting your app.

Get the Amazon Mobile App SDK Eclipse Plugin

This article was re-printed with permission from Amazon Digital Services, Inc.
This site does business with Amazon Digital Services, Inc.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Latest Posts

Related Stories