Creating Your First Kindle Fire App

Introduction

If you have not yet created an app for a Kindle Fire tablet, you can use Eclipse to create a Hello Kindle Fire app. For more information about how to create your first Android app, in the Android documentation see the tutorial.


Prerequisites

Before you begin, you must have already set up your development environment. For more information, see Setting Up Your Development Environment.


Creating Your App

To create a Hello Kindle Fire app, you first need to create a new project in Eclipse:

  1. Open Eclipse.
  2. On the File menu, click New, and then click Project.
  3. In the New Project window, under Android, click Android Application Project, and then click Next.
  4. In the New Android Application window, in the Application Name box type HelloKindleFire.
    You can choose a minimum required SDK, target SDK, and version with which to compile, but make sure that you target and compile for API 15 or later.
  5. Click Next several times until you reach the Blank Activity window.
  6. In the Blank Activity window, in the Activity Name box type HelloKindleFireActivity, and then click Finish.

The Package Explorer pane now lists your project.

Package Explorer showing Hello Kindle Fire

A Brief Overview of Android Apps

To help you better understand the next steps for our Hello Kindle Fire app, the following introduces a few basic concepts about Android apps.

In our Hello Kindle Fire app, there are three primary components:

  • HelloKindleFireActivity.java - This is the core logic specific to the app. It is also typical Java code for an Android activity.
  • activity_hello_kindle_fire.xml - In Android applications, a recommended convention is to lay out all user interface (UI) elements in a dedicated XML file. For this example, we use the dedicated XML file activity_hello_kindle_fire.xml from the res/layout subdirectory of the project to define the layout for our activity. Doing so simplifies the UI design, so that making changes does not require digging through core logic. The creation of class R includes this dedicated XML file, and the core logic can reference R to manipulate the UI elements. However, laying out UI elements in a dedicated XML file is not the only way to define and lay out UI elements. You can also define the UI elements inline with the code as with any other Java application.
  • strings.xml - Another convention in Android applications is to put string values of UI elements such as labels in a dedicated XML file. This practice is equivalent to using a Java resource file that provides a path to localize UI elements. This makes it easier to find strings in your application without having to dig through the code. This dedicated XML file, located in the res/values subdirectory, holds key-value mappings. The key identifies the UI element in the layout, and the value is the string that appears when the application runs.

Customizing Hello Kindle Fire

To edit the Hello message in the app:

  1. Under the HelloKindleFire project, open the res folder and then the values folder.
  2. Double-click strings.xml.
  3. Under Resources Elements, select hello_world (String), and then in the Value box enter Hello, Kindle Fire.
  4. On the File menu, click Save to save your changes to the strings.xml file.

You are now ready to run your Hello Kindle Fire app.


Next Steps

If you want to run your app on the Kindle Fire emulator, you need to set up your emulator first. For more information, see Running the Kindle Fire Emulator.

If you want to use a physical Kindle Fire tablet, see Setting Up Your Kindle Fire Tablet for Testing.


Return to Kindle Fire
Unavailable During Maintenance