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.
Before you begin, you must have already set up your development environment. For more information, see Setting Up Your Development Environment.
To create a Hello Kindle Fire app, you first need to create a new project in Eclipse:
- Open Eclipse.
- On the File menu, click New, and then click Project.
- In the New Project window, under Android, click Android Application Project, and then click Next.
- In the New Android Application window, in the Application Name box type
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.
- Click Next several times until you reach the Blank Activity window.
- In the Blank Activity window, in the Activity Name box type
HelloKindleFireActivity, and then click Finish.
The Package Explorer pane now lists your project.
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
res/layoutsubdirectory 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
Rincludes this dedicated XML file, and the core logic can reference
Rto 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/valuessubdirectory, 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:
- Under the HelloKindleFire project, open the res folder and then the values folder.
- Double-click strings.xml.
- Under Resources Elements, select hello_world (String), and then in the Value box enter
Hello, Kindle Fire.
- On the File menu, click Save to save your changes to the
You are now ready to run your Hello Kindle Fire app.
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|