Create Your First Fire Tablet App
If you have not yet created an app for a Fire tablet, you can use Android Studio to create a Hello Fire app. For more information about how to create your first Android app, in the Android documentation see the tutorial.
- Create Your App in Android Studio
Before you begin, you must have already set up your development environment. For more information, see Setting Up Your Development Environment for Fire Tablets.
Create Your App in Android Studio
To create a Hello Fire app, you first need to create a new project in your IDE. Use the following steps to create a new project in Android Studio:
- Open Android Studio.
- On the File menu, click New Project.
- In the New Project window, in the Application name box type HelloFire. 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 twice.
- In the Activity Name box type HelloFireActivity, and then click Finish.
The Project pane now lists your project.
A Brief Overview of Android Apps
To help you better understand the next steps for our Hello Fire app, the following introduces a few basic concepts about Android apps.
In our Hello Fire app, there are three primary components:
- HelloFireActivity.java - This is the core logic specific to the app. It is also typical Java code for an Android activity.
- activity_hello_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_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. Instead of laying out UI elements in a dedicated XML file, you can 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 Fire
To edit the Hello message in the app:
- Under the HelloFire project, open the app>src>main>res folder and then the values folder.
- Change the hello_world string to
- On the File menu, click Save to save your changes to the strings.xml file.
You are now ready to run your Hello Fire app.