How to Build and Run the Android Application

Every Android Application is composed of following files. In this post, we share How to Build and Run the Android Application.

  • AndroidManifest.xml
  • R.java and Resources
  • Layouts (main.xml)
  • Activities (Java Class File)

 

AndroidManifest.xml

The components and settings of an Android application are described in the AndroidManifest.xml file. For example all Activities and Services of the application must be declared in this file. It must also contain the required permissions for the application. For example if the application requires network access it must be specified here.

 

To include new Activity use

<activity android:name=“com.org.net.DisplayMessageActivity” />

OR

<activity android:name=“com.org.net.DisplayMessageActivity” > </activity>

To inform the system which implicit intents they can handle, activities, services, and broadcast receivers can have one or more intent filters. Each filter describes a capability of the component, a set of intents that the component is willing to receive. It, in effect, filters in intents of a desired type, while filtering out unwanted intents — but only unwanted implicit intents (those that don’t name a target class). An explicit intent is always delivered to its target, no matter what it contains; the filter is not consulted. But an implicit intent is delivered to a component only if it can pass through one of the component’s filters.
“@string/app_home”  means app_home name is define in string,xml file and reference is stored in R.java  file.(String.xml file is present in “res/values” folder.

 

R.java and Resources

R.java is resources file which is automatically generated by Eclipse IDE. Do not try to edit this file. The gen directory in an Android project contains generated values. R.java is a generated class which contains references to certain resources of the project. These resources must be defined in the res directory and can be XML files, icons or pictures. You can define values, menus, layouts or animations via XML files.
If you create a new resource, the corresponding reference is automatically created in R.java via the Eclipse ADT tools. These references are static integer values and define IDs for the resources. The Android system provides methods to access the corresponding resource via these IDs. For example to access a String with the R.string.yourString ID, you would use the getString(R.string.yourString)) method.
R.java is automatically created by the Eclipse development environment, manual changes are not necessary and will be overridden by the tooling.

Layout (main.xml)

This file will contain the layout of android screen. The user interface for Activities is defined  with this layout file. The layout defines the included Views (widgets) and their properties. A layout can be defined via Java code or via XML. In the most cases, the layout is defined as an XML file.
XML based layouts are defined via a resource file in the /res/layout folder. This file specifies the ViewGroups, Views, their relationship and their attributes for this specific layout. If a View needs to be accessed via Java code, you have to give the View a unique ID via the android:id attribute. To assign a new ID to a View use @+id/yourvalue . The following shows an example in which a Button gets the button1 ID assigned.
Path of this file is Project > res > Layout.

 

 

In your XML files, for example your layout files, you can refer to other resources via the @ sign. For example, if you want to refer to a color which is defined in a XML resource, you can refer to it via @color/your_id. Or if you defined a “hello” string in an XML resource, you could access it via @string/hello.

 

Activity (Java Class File)

This file contain application logic means which action will performed by your application. This class is subclass of Activity class. When your application is launched it will call it’s onCreate() method.

 

 

To run the applications simply click on Run Button android _ run_clip on Toolbar.
Keyboard shortcut is ctrl + F11. This will show the following screen and here you run your first android program.

android application_ run_clip
android application_ run_clip

Full android web application Tutorial:-

Introduction How to develope Android application

What are the Fundamental Units of Android Application

Step by Step Installation guid for android application developent

How to Build and Run the Android Application

Views in Android Application

Linear Layout in Android Application Development

Table Layout in Android Application

Relative Layout in Android Application

SQLite Database used in Android Application Development

Music Player Code for Android Application Development

How to make Phone call for Android Application with full code

Status Bar in Android Application Development with Full Code

Comments

comments

2 Comments
  1. Twitter23 says

    Hi, just wanted to say i liked this article. it was practical. keep on posting.

    1. PcSkull says

      Thanks 🙂

Leave A Reply

Your email address will not be published.