Posted by : Diana Middlebrook
Android operating system is one of the most important OS of our age. Due to its open ended nature Android OS can be easily manipulated to come up with wonderful apps which can even change the lifestyle of the users. This blog post would be taking you through the beginners’ guide of Android app development through the use of the software application Eclipse 4.3.
As a novice to deal with app development, you should not have to know anything about JAVA programming in details but a little bit of .xml knowledge is required. The following lines of the post would be guiding you through utility of Eclipse along with resources and help in the creation of the codes. This tutorial would be the stepping stone to becoming the Android Application Developer.
You have to follow few steps even before starting with the Android development tools. Firstly download The Eclipse IDE from www.eclipse.org /downloads/ > download and install SDK Starter Package from http://developer.android.com/sdk/index.html . The instructions about SDK would be found on http://developer.android.com/installing.html .
The Android SDK would be providing you with an access to a library of API or Application Programming Interfaces and developer tools which is required to build, test and debug apps for an Android App. ADT or the Android Developmental Tool.
It is mandatory for you to set the environment to run the development process. If you are still not aware of the environment, check the Path of the environment. If you are using a windows system, you would be finding it under “Control Panel>System>Advanced System Settings>Environment Variables” in the lower list box. It is best to find out the JAVA version which can be found on your computer. Go to the command line and type- java -version. You would have a complete detail about your Java version.
The first application we would be dealing would be the hello world application, the default application for any beginner to the Android Operating System. Initiate the Eclipse program. After initiating the program you should select File>New>Project. When you come across the new project dialog, select Android>Android Application Project and click Next.
The above screenshot would direct you to a window where you would be able to set up the project. You should start the project with a project name. As it is your first project, your project name should be set as ‘Hello World’ by default. From the Android site you have to choose which version to use. The best option for your case would be Android Version 4.3 which can be found in the following list which is mentioned below. As you would be requiring API version 8, it is mandatory for you to type the numeric value of 8 in the Min SDK version box.
When giving the name for those applications, you should not be leaving any white spaces as the name would be used further in codes e.g. ‘helloworld’. Keep the application name all letters in small caps.
The next step involves everything about defining the package of the project. The definition of the package would involve something like com.example – helloworld.
You have the option to save the project to a different directory of your choice. The default directory where the operating system is installed would be the best option for you.
The next window which you would be coming across would be the default icon page for the app. You can either select the default icon or you can choose an image of your own just by opting the browsing option.
The next window would comprise the activity selection options. Click on the ‘next’ button to select the default activity (blank activity).
It becomes mandatory to know the name of the activity. In your case you can always name it ‘Main Activity’. Name the layouts according to your choice as well as the navigational type.
Your Hello World app would be created and would be ready for configuration.
The next step before we start the project is all about configuring. The configuration is done for the sake of tweaking and tuning control as well as checking the network speed of the emulator. You can always choose different types of emulators for the testing of the app through different versions and different screen size. Start your configuration by going to Run > Run configuration. Next click on the Android Application tab on the left column, and then click on the new button, to start with the new configuration.
Come up with a name for the new configuration, something like ‘New_Configuration’ without any whitespace.
Now select your project ‘helloworld’ over the browse button. You should move on to the target tab. Here you would be able to select the emulator as well as the network speed. Click the automatic control to enable the buttons on the left column followed by clicking on the manager-button. Now you can click the Run button on the left hand bottom corner of the window to get the new emulator. You can always rename the emulator such as Default Android emulator. In this emulator you can specify details such as Android version as well as your hardware and skin. You have the ability to control all the abilities of a virtual Android phone from the emulator you have created.
After you are done with making the emulator, click on the AVD and close the manager window. The run configurations are now created and you are ready to run the device. Click the OK button and close the application. The emulator takes a little time to start up. Voila! You have the emulator ready for your apps.
The main essence of an Android app is the code. After the emulation is complete, it’s all about coding. But even before getting on with the Java code, you have to have a clear understanding of the Android code.
Go to the package explorer, and get your ‘Hello World’ project enlarged. There you would be encountering 5 folders and 2 files. It is here you would be coming across the Android manifest files. The manifest file comprises each and every detail including the icon, the name of the author etc. To open the file you have to right click on it and open the file from Open with… > Android manifest editor. The tab which would come up in front of you, you have to specify the package name and the version of the project. Most of the settings are quite self-explanatory can be filled up by you easily. You would be finding @ character in front. The strings with the ‘@’ character in front is a reference to resources. The resource would be available in the “res” folder of your project. Elements with the likes of valuable, drawable, layout, animations, xml, styles and raw should have to be placed in this folder. You ought to be focusing on the values folder first. This is the ideal place to store resources such as strings, colors, numbers, dimension and arrays. The strings.xml file is available in the folder by default. Use the right click to come up with Open with… > Android layout editor. The file would include two specific values. The first would be the name of the project and the message which is to be displayed when you run the files. You can use more values if you want to use them in the code. You can also use quantifiers to create resources. If you can use a – along with the folder’s name then it would be easy to use the quantifiers. If you are planning to launch the Android software globally then use English. You have to change the values folder to values-en. You can have all your content to be used through the application in English. If any kinds of quantifiers are not added, the resources would be left default. The default resources are used if no specific resources are available.
After your project is being initiated, the default resources will be compiled as efficiently as possible and would be added to the package. Along with this a reference would be created namely ‘R’ which would help you to access the resources part of the code. But this tutorial will not be focusing on the varying types of resources but the programming aspect only.
Now the actual coding process will start. At this juncture you have to go to the SRC folder. Within the SRC folder you will get hold of the package folder where you will get hold of the helloworld.java file. The default code for the Android activity is given below:
A new activity would be created using the default Android activity class. The Oncreate function has to be overridden which should be replaced by the layout from the resources and also call the Oncreate function of the base class. Get hold of the layout file located under the layout folder of the resources. You would be finding these codes inside.
The root node in this case would be called linear layout. The Linear layout is only one type which is available from the gamut of layouts. The other layout you can choose from includes frame layout, relative layout, table layout and absolute layout.
After the layout type is chosen, you have to add child elements. The Textview is used to display text on the screen. The values.xml is defined through the resource in this context. The value takes the whole width of the screen. The whole thing should be started through making small changes.
The next step is to add the project and observe the changes. Now it is time to add the Edit Text:
At this point you have to analyze the code word by word. You have to load the layout and get on with the creation of the TextView as well as an EditText variable. It’s time to load your interface objects in them. You have to create an ONKey through the ONKey Listener. This tool reacts to any of the keys which are pressed when the phone is active. Now you have to continue with two last checks: make sure that the key are pressed down and not released. Secondly, you have to specify and map the key. When both of these tests come with positive results, add the text to Edit Text control located in the Text View. Finally, you can delete the control of the Edit Text. After all the previous steps are covered, you can run and test the application. Congratulation! Now you have your very own Android App and you can call yourself a professional Application Developer in Android.
But this doesn’t conclude the process of Android App Development. The next stage continues with Android App Design which would be covered in the next post. If you have any opinion about Android App Development of your own, you can always discuss in the comment section below.