Android Hello World Application Tutorial
- Posted by asifmujteba on 12.09.2011
- 2 feedbacks »
This simple tutorial helps you to write a simple android hello world application, so that you can quickly start developing android applications. Note: this is a beginner level tutorial for some one who wants to create his first android application, the aim here is to get you introduced to android framework, setting up environment and create a basic application.
A Word about Android (What is Android?)
Android is an open source operating system built by Google on top of linux kernel, which is mainly targeted for mobile devices and tablet PCs. Android is used by a great number of carriers and installed on a lot of mobile phone under the Open Handset Alliance (A large group of companies contributing to Android OS ).
Android OS is like a software stack consisting of base OS, middle ware (containing Various libraries and APIs), Application framework and key applications. A developer SDK is provided in order to access the application framework and build applications which are capable of running on Android's DVM (Dalvik Virtual Machine).
Setting Up Android Development Environment
- Download and Install latest JDK from Java website
- Download and Install latest version of eclipse Java IDE from Eclipse website
- Download latest Android-sdk.zip file from Android website, unzip and save it root of the directory where you installed eclipse IDE
- Download and Install Eclipse ADT plugin From Here
Creating the Application
After all that, now lets create the android application. Open Eclipse IDE and create a new Project by going to File->New->Android Project, which would bring up new Android Project Wizard, go ahead and name your Project Hello World Application, Choose Android 1.6 as build target, name application to HelloWorldApp, specify a valid package name like org.modev.android.hello (Specifying a package name is necessary as android identifies the app through it package name). Check the Create Activity checkbox and specify Activity name MainActivity. Lastly specify Min sdk version to 4 and click finish to create the Project.
![]() |
Exploring Android's Project Directory Structure
![]() |
- MainActivity.java is the main activity class we mentioned in above dialog
- gen/R.java this is auto generated files which android uses for its internal processing storing information to all components and resources, editing this file manually is strictly prohibited
- android.jar this is the library jar file for development only
- assets currently this folder is empty but it contains project resources like fonts and .db files
- res/drawable-* these folders contain project images, as there name suggest we place different version of images in these folders which android automatically senses and picks right version, for e-g, hdpi folder contains high res images
- res/layout this folder contains the xml files for our views, In android views are separately made using xml files
- res/values folder contains common strings and constants files
- AndroidManifest.xml The main controller of the application which contains all necessary information about the application and its flow, for e-g, it contains application icon link, list of activities, permissions it uses etc
You can further open the files and review the code for understanding.
MainActivity.java
Code:
package org.modev.android.hello; | |
| |
import android.app.Activity; | |
import android.os.Bundle; | |
| |
public class MainActivity extends Activity { | |
/** Called when the activity is first created. */ | |
@Override | |
public void onCreate(Bundle savedInstanceState) { | |
super.onCreate(savedInstanceState); | |
setContentView(R.layout.main); | |
} | |
} |
main.xml
Code:
<?xml version="1.0" encoding="utf-8"?> | |
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |
android:orientation="vertical" | |
android:layout_width="fill_parent" | |
android:layout_height="fill_parent" | |
> | |
<TextView | |
android:layout_width="fill_parent" | |
android:layout_height="wrap_content" | |
android:text="@string/hello" | |
/> | |
</LinearLayout> |
AndroidManifest.xml
Code:
<?xml version="1.0" encoding="utf-8"?> | |
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | |
package="org.modev.android.hello" | |
android:versionCode="1" | |
android:versionName="1.0"> | |
<application android:icon="@drawable/icon" android:label="@string/app_name"> | |
<activity android:name=".MainActivity" | |
android:label="@string/app_name"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN" /> | |
<category android:name="android.intent.category.LAUNCHER" /> | |
</intent-filter> | |
</activity> | |
| |
</application> | |
<uses-sdk android:minSdkVersion="4" /> | |
</manifest> |
Running Android Application in Emulator
The sdk provides built in Emulator known as AVDs which emulate specific Android os versions and specific screen sizes, You can create a new Android Virtual Device from the Android SDK Manager. Now go ahead and right click in the project and click RUN Project, this would bring the emulator loaded with our Hello World App, be patient the emulator start up could take up to few minutes.
In Android
[Solved] J2ME Sony Ericsson Emulator Error: Couldn't load zayitlib.dll file
- Posted by asifmujteba on 11.30.2011
- Send feedback »
yesterday, I installed Sony Ericsson j2me wtk sdk on my development machine and tried to configure it with netbeans 6.1 IDE, the integration was quite easy and quick, but when I tried to run my j2me application on the emulator, the simulator just disappeared after couple of seconds and this error appeared on debug console "Error: couldn't load Zayitlib.dll file", after searching the internet i figured out that problem occurs usually on windows xp service pack 3, and it can be easily resolved by using the following method.
VaMp_50.dll, SPOTCorePlayer_51.dll, SPOTxdePlayerDLL.dll, VaAce.dll
After that just try to start the emulator again and your problem would be solved.
If you liked this post or this tutorial helped you than dont hesitate to click the Google +1 like button
In J2ME
How to display J2ME application in full screen mode
- Posted by asifmujteba on 11.21.2011
- Send feedback »
While developing j2me games or other apps you may run into a situation where you would need to hide the menu buttons and title bar and display the application in true full screen mode, running application in fullscreen mode enables the app to capture more space on the screen and enrich the user experience but on the other side it also adds a great responsibility on the application, you have to handle to screen navigation yourself and display proper title of the current screen being displayed, Make sure that you have provided a way for user to exit the application. Use the code below to make your j2me application run in full screen mode.
Code:
Code:
// Note: this function is only available for Canvas class or its subclasses | |
| |
this.setFullScreen(true); |
In J2ME
J2ME Application - Hide Virtual keyboard / keypad for touch screen devices
- Posted by asifmujteba on 11.21.2011
- Send feedback »
On Touch screen devices, Virtual keyboard also known as Soft Keypad usually appear by default when you run your J2ME application. This great feature designed for touch screens can sometimes turn out to be a great discomfort and ruin your whole application experience, especially, If you are developing games than this is the feature which you need to turn off. Hiding this virtual keyboard, enables the J2ME application to occupy more space and and listen to touch events, You can easily hide the virtual keyboard using .jad file configurations just add the following attributes in your .jad file.
Code:
Code:
// hide virtual keyboard | |
Nokia-MIDlet-On-Screen-Keypad: no | |
| |
Nokia-MIDlet-On-Screen-Keypad: no | |
| |
MIDlet-Touch-Support: true |
In J2ME
J2ME - How to Fix Application's Screen Orientation to Landscape / Portrait Mode [Solution]
- Posted by asifmujteba on 11.21.2011
- 1 feedback »
In J2ME, application's screen orientation can only be fixed by using .jad file attributes. There is no explicit java code or method to do this. If you are developing a j2me mobile application which targets Accelerometer enabled devices, than you might run into screen orientation issues. There are two basic types of screen orientations when dealing with mobile phones:
| 1- Portrait Mode (Screen has more space vertically) 2- Landscape Mode (Screen has more space horizontally) |
Suppose, If you have designed your application for specific orientation mode and when running on actual device if user rotates the device this can ruin the whole app experience and sometimes the app may even crash. To fix this problem you need to set the desired application orientation mode in the jad file like this:
Code:
// for portrait mode | |
Nokia-MIDlet-App-Orientation: portrait | |
| |
// for landscape mode | |
Nokia-MIDlet-App-Orientation: landscape |
If you have found this tutorial helpful by any means than you may click on the google +1 button below, it would be really appreciated
In J2ME

