Let Go for Create First Android App.
Hello World Android Application in Eclipse
This post will help you to create and run Hello World Android Project in Eclipse.
To continue developing your first android application you need to download Android SDK first. You can find this tutorial in Configure Android on PC
- Open eclipse, set your working folder then go to File –>New – >Android Application Project.
- Here you will have to fill some details which are described clearly below.Application Name: Application name should be a user friendly name. This name will be displayed everywhere to identify your application. For example ‘Angry Birds’, ‘Talking Tom’ are some of the application names.Project Name: This need not be taken care much as this name is used as an identifier in eclipse. This can be same as your application name or even some other name as developer’s choice but to maintain integrity same name as application name is preferred to use.Package Name: Package name is something which has to be given some importance similar to Application name. Android packages follow same conventions as Java packages so this must be a valid Java package name. Package name cannot be changed later. It should have atleast two identifiers.
- Then proceed with other default settings, the last pop will be the Activity screen. Now you should be able to view something like the below screen.
Java Source Code
Let's see the java source file created by the Eclipse IDE:File: MainActivity.java(1) Activity is a java class that creates and default window on the screen where we can place different components such as Button, EditText, TextView, Spinner etc. It is like the Frame of Java AWT.It provides life cycle methods for activity such as onCreate, onStop, OnResume etc.(2) The onCreate method is called when Activity class is first created.(3) The setContentView(R.layout.activity_main) gives information about our layout resource. Here, our layout resources are defined in activity_main.xml file.File: activity_main.xmlAs you can see, a textview is created by the framework automatically. But the message for this string is defined in the strings.xml file. The @string/hello_world provides information about the textview message. The value of the attribute hello_world is defined in the strings.xml file.File: strings.xmlYou can change the value of the hello_world attribute from this file.
Generated R.java file
It is the auto-generated file that contains IDs for all the resources of res directory. It is generated by aapt(Android Asset Packaging Tool). Whenever you create any component on activity_main, a corresponding ID is created in the R.java file which can be used in the Java Source file later.File: R.java
APK File
An apk file is created by the framework automatically. If you want to run the android application on the mobile, transfer and install it.
Resources
It contains resource files including activity_main, strings, styles etc.
Manifest file
It contains information about package including components such as activities, services, content providers etc.For more information about manifest file visit here: Android Manifest.xml file.- Application Name is HelloWorld. To run and view this application in Android Emulator Right click on your project and click RunAs Android Application as shown below
- Now you must be able to see you application in Android emulator as shown below. You need to unlock the virtual phone to view your application. Or if you face any database connectivity issues it must be due to your firewall settings or Antivirus. If not you will be able to see the below screen

Now we are done with basic Hello world application in Eclipse.



No comments:
Post a Comment