What is Android?

What is Android?
Android is an operating system developed by Google that is dedicated to mobile devices.Android is based on Linux.Android core libraries are written in C ,C++ and Java.Android platform is written in Java.Android uses a virtual machine - Dalvik.Android offers a set of APIs in the Java language for application developers.

Activity :  Activity is the presenter of a single screen in the application. It is the only one who has certain abilities, like displaying Views, menus, alerts and notifications. It also has the ability to open a new Activity, which means opening a new screen.Activity is a class which derives from android.app.Activity.An application needs to have at least one Activity.All Activities must be declared in the manifest file. 
View : A view is a single user interface element. Its responsibilities include drawing on a canvas and handling user events.  Some Views can contain other Views, these are called view groups.  A View is a class which derives from android. There are already many existing views. The developer can use them or create his own customized view by extending any of them.

Intent : Intent is the negotiator between two activities or between two applications. It gives the ability to pass messages and data between the two entities.  When writing applications for mobile, Intent is very handy, since it gives access to a lot of the OS services like opening the camera, a browser, displaying notifications and so on

Service : A Service is an application which has the ability to run in the background without displaying any user interface.  A Service is a class which derives from android.app.Service.  All Services must be declared in the manifest file

Environemnt Installation
Option 1 - Eclipse Plugin
If you have an Eclipse installed and you wish to continue working with it, you can do so by installing the Android Eclipse Plugin.

Option 2 - Android Development Tools (ADT) Bundle
The ADT Bundle is a complete package of Eclipse with Android plugin and Android SDK with all the extra tools. So this is probably a good options if you are starting from scratch.

Option 3 - Android studio
If you like inteliJ morte than a Eclipse, than this is probably the best option for you. This one also includes every thing the ADT bundle includes.

Creating a project
In Eclipse: Select File > New > Android Project.
In Android Studio: Select File > New Project.

Enter the project properties: 
Application name - this is how the user sees the title of your application
Project Name - The java eclipse project name.
Build SDK - The Android SDK version you will use to develope your application.
Minimum required SDK - The minimum Android API version to be supported by your application.
Package name - Android demands each application to declare its root package

Click on 'Next' twice

Create Activity + Activity name Click on 'Finish'.

An Android project structure
Manifest file : Android Mani fest.xml defines the Android application project. It defines the attributes, activities, versions, permissions, and other parameters of the application.
'src' folder :As any Java project, this folder holds all the Java sources and packages.

'res' folder :Holds any local resources of the application:
'drawable' - image folders according to resolutions. By default there are 3 folders for 3 basic resolutions.'layout' - xml files which represent display layout. By default a main.xml is created.'values' - xml files which define global constants, strings, styles or colors.
*Note: files in the res folder may be modified for optimization purposes.

SDK jar: Holds the android.jar which is different from versions of the SDK.
'gen' folder: Contains the R class which is a class that is automatically generated by the Eclipse plugin and gives access to the projects resources.
'assets' folder: Holds other raw resource files such as movies or sound files. By default this folder is not created. These resources will not be modified.

Creating Android Virtual Device (AVD): The developer can test his applications on an emulator which comes along with Android SDK.  But first the developer has to define a virtual device which suits his needs.

To create an AVD:
In Eclipse: select Window > AVD Manager
   In Android Studio: select Tools > AVD Manager
   or click the AVD Manager icon from the toolbar.In the Virtual Devices panel, you'll see a list of existing AVDs. Click New to create a new AVD.Fill in the details for the AVD and click "Create AVD".

Signing and generating jars
Android applications as other applications are zipped to jar files. The only difference is that Android jar files have a different extension - .apk. All application jars have to be signed before they are installed. Please follow instructions in: http://developer.android.com/guide/publishing/app-signing.html

Creating and adding a new View to a Layout
XML example - Adding to a view in a layout xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout  xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mainLayout" >
    android:text="My text view"
Code example - Creating and adding a new view to a Layout (implemented in an Activity class).
TextView textView = new TextView(this);
textView.setText("My Text View");
        textView ,
        new LayoutParams(LayoutParams.MATCH_PARENT,

View Groups

A ViewGroup is a special view that can contain other views.

List view

ListView list = new ListView(this);
String[] listItems = {"Option 1","Option 2","Option 3"};
list.setAdapter(new ArrayAdapter<String>(
                this,android.R.layout.simple_list_item_1, listItems ));
list.setOnItemClickListener(new OnItemClickListener() {
      public void onItemClick(AdapterView<?> parent,
                    View view, int position, long id) { 
             Log.d("ListView test", "Item " + id + " was selected.");


Spinner (drop down list)

Spinner spinner = new Spinner(this);
spinner.setAdapter(new ArrayAdapter<String>(this,
android.R.layout.simple_spinner_item, listItems ));
spinner.setOnItemSelectedListener(new OnItemSelectedListener() {
     public void onItemSelected(AdapterView<?> parent,
                View view, int position, long id) {
              Log.d("Spinner test", "Item " + id + " was selected.");
     public void onNothingSelected(AdapterView<?> parent) {

Please Share :
Next Post »
Comment This Article : "What is Android?"
Feedback :
Back To Top