Home » Writing » Tutorial writing your first android app

Tutorial writing your first android app

Tutorial writing your first android app tutorial step by step to

Let’s start actual programming with Android Framework. Before you begin writing the first example using Android SDK, you need to make certain you have set-your Android development atmosphere correctly as described in Android – Atmosphere Set-up tutorial. I additionally assume that you’ve a tiny bit working understanding with Eclipse IDE.

So let’s go to write an easy Android Application that will print “Hello World!”.

Create Android Application

The initial step is to produce a simple Android Application using Eclipse IDE. Stick to the option File – New – Project and lastly select Android New Application wizard in the wizard list. Now name the application as HelloWorld while using wizard window the following:

Next, do as instructed provided and other records as default up until the final step. When your project is produced effectively, you’ll have following project screen −

Anatomy of Android Application

Prior to running your application, you should know of the couple of directories and files within the Android project −

Folder, File Description

This offers the .java source files for the project. Automatically, it offers a MainActivity.java source file getting a task class that runs whenever your application is launched while using application icon.

This offers the .R file, a compiler-generated file that references all of the sources present in any project. You shouldn’t modify this file.

This folder offers the Android package files .apk built through the ADT throughout the build process and anything else required to run an Android application.

This can be a directory for drawable objects that are equipped for high-density screens.

This is actually the manifest file which describes the essential characteristics from the application and defines all of its components.

Tutorial writing your first android app studio     
   There are so many

Following section can give a short overview couple of from the important application files.

The Primary Activity File

The primary activity code is really a Java file MainActivity.java. This is actually the actual application file which ultimately will get transformed into a Dalvik executable and runs the application. Following may be the default code generated through the application wizard for Hello World! application −

Here, R.layout.activity_primary refers back to the activity_primary.xml file found in the res/layout folder. The onCreate() method is among many techniques that are figured when a task is loaded.

The Manifest File

Whatever component you develop as part of the application, you have to declare its components inside a manifest.xml which resides at the bottom from the application project directory. This file works being an interface between Android Operating System as well as your application, so if you don’t declare your component within this file, then it won’t be considered through the OS. For instance, a default manifest file may be like as following file −

Here application. /application tags enclosed the constituents associated with the applying. Attribute android:icon points towards the application icon available under res/drawable-hdpi. The applying uses the look named ic_launcher.jpg found in the drawable folders

The activity tag can be used to specify a task and android:name attribute specifies the properly accredited class name from the Activity subclass and also the android:label attributes specifies a string for the label for that activity.

Tutorial writing your first android app Following is the default

You are able to specify multiple activities using activity tags.

The action for that intent filter is known as android.intent.action.Primary to point this activity can serve as the access point for that application. The category for that intent-filter is known as android.intent.category.LAUNCHER to point the application could be launched in the device’s launcher icon.

The @string refers back to the strings.xml file described below. Hence, @string/application_name refers back to the application_name string defined within the strings.xml file, that is “HelloWorld”. Similar way, other strings get populated within the application.

Following may be the listing of tags which you’ll use within your manifest file to specify different Android application components:

activityelements for activities

service elements for services

receiver elements for broadcast receivers

provider elements for content providers

The Strings File

The strings.xml file is situated in the res/values folder also it contains all of the text that the application uses. For instance, what they are called of buttons, labels, default text, and other alike kinds of strings get into this file. This file accounts for their text message. For instance, a default strings file may be like as following file −

The R File

The gen/com.example.helloworld/R.java file may be the glue between your activity Java files like MainActivity.java and also the sources like strings.xml. It’s an instantly generated file and you ought to not customize the content from the R.java file. Following is really a sample of R.java file −

Design File

The activity_primary.xml is really a layout file obtainable in res/layout directory, that’s referenced from your application when building its interface. You’ll modify this file often to alter design of the application. For the “Hello World!” application, this file may have following content associated with default layout −

It is really an illustration of simple RelativeLayout which we’ll study inside a separate chapter. The TextView is definitely an Android control accustomed to build the Graphical user interface also it have various attributes like android:layout_width. android:layout_height etc which are used to create its height and width etc. The @string refers back to the strings.xml file found in the res/values folder. Hence, @string/hello_world refers back to the hello string defined within the strings.xml file, that is “Hello World!”.

Running the applying

Let us attempt to run our Hello World! application we simply produced. I suppose you’d produced your AVD while doing atmosphere set-up. To operate the application from Eclipse, open your project’s activity files and click on Run icon in the tool bar. Eclipse installs the application in your AVD and starts it and when things are fine together with your set-up and application, it’ll display following Emulator window −

Congratulations. you’ve developed the first Android Application and today keep following remaining tutorial step-by-step to become great Android Developer. All the most effective.

Create Android Application on Android studio

There are plenty of tools are for sale to develop android applications. according to Google official android development, they’ve launched android studio as official Android IDE


Share this:
custom writing low cost
Order custom writing

ads