Exploring the Android application environment

The Android environment for Worklight apps provides complete implementation and structured resource handling for handling the environment. Here, we have to generate the Android native project by deploying the Android environment added to the Worklight project/app. Follow the given steps to initialize the Android project for a particular environment:

  1. Right-click on apps and navigate to HelloWorld | android.
  2. On the menu that appears, select Run As | 2 Build Environment and Deploy. After clicking on this option, the deployment process will start and the status can be seen in the Console window under Worklight Studio | Eclipse.
  3. After deployment of the environment, you can see the Android project generated in the same workspace with a combination of project name, app name, and selected mobile/desktop environment.
Exploring the Android application environment

An Android project generated after build

The the Android application is finally generated and ready to execute with the resources. Now, we will brief you about the Android native project resource structure. You will see a basic Android application. The following table describes the structure and information of each folder that every Android project contains:

Folder

Description

src

This folder holds the Java files.

gen

Once the project is compiled with no error, this folder holds the generated Java files by Android Development Toolkit. It also includes R.java and interfaces created from the Android Interface Definition Language (AIDL) files.

res

This folder is used to store application resource files, including drawable files such as images, application activities layout files, and string values.

res/drawable

The drawable folder is used to store the several bitmap files such as PNG, JPEG, GIF, and 9-patch image files and a list of drawable resources supported by the Android OS.

res/values

The values folder holds XML files that are used to store various strings specifying name and variable relationships. These strings are generated by reference in the R class for them to be accessed anywhere in the project.

res/layout

The layout folder holds the layout files. They are written in XML and are used to define and organize Android objects (for example, textboxes, buttons, and so on) on the screen with different layouts supported in the Android OS.

Android also has some major files in the project. Let start exploring them one by one:

  • AndroidManifest.xml: This XML file is one of the core files of the Android project. It holds overall information about application services and activities and is used to define permissions for applications such as allowing an application to access the Internet or allowing an application to write.
  • MainLayout.xml: This file describes the layout of the page. This means it is responsible for the placement of every component (such as textboxes, labels, radio buttons, user defined components, and so on) on the app screen.
  • Activity: Every application that occupies the entire device screen needs at least one class that inherits from the Activity class. One major method is called OnCreate. This method initiates the app and loads the layout page.

There are a variety of devices powered by Android, and not all of them provide the same features and capabilities. In order to prevent your application from being installed on devices that lack features needed by your application, it's important that you clearly define a profile for the types of devices your application supports by declaring device and software requirements in your manifest file.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.220.98.14