Android

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

Android(Mobile OS) is a complete set of software for mobile devices such as tablet computers,

notebooks, smartphones, electronic book readers, set-top boxes etc.


It contains a linux-based Operating System, middleware and key mobile applications.
It can be thought of as a mobile operating system. But it is not limited to mobile only. It is
currently used in various devices such as mobiles, tablets, televisions etc.
History of Android
The history and versions of android are interesting to know. The code names of android ranges
from A to J currently, such
asAestro, Blender, Cupcake, Donut, Eclair, Froyo, Gingerbread, Honeycomb, Ice Cream
Sandwitch, Jelly Bean, KitKatand Lollipop. Let's understand the android history in a sequence.
1) Initially, Andy Rubin founded Android Incorporation in Palo Alto, California, United States
in October, 2003.
2) In 17th August 2005, Google acquired android Incorporation. Since then, it is in the subsidiary
of Google Incorporation.
3) The key employees of Android Incorporation are Andy Rubin, Rich Miner, Chris
White and Nick Sears.
4) Originally intended for camera but shifted to smart phones later because of low market for
camera only.
5) Android is the nick name of Andy Rubin given by coworkers because of his love to robots.
6) In 2007, Google announces the development of android OS.
7) In 2008, HTC launched the first android mobile.

Android Versions, Codename and API


Let's see the android versions, codenames and API Level provided by Google.
Version

Code name

API Level

1.5

Cupcake

1.6

Donut

2.1

Eclair

2.2

Froyo

2.3

Gingerbread

9 and 10

3.1 and 3.3

Honeycomb

12 and 13

4.0

Ice Cream Sandwitch

15

4.1, 4.2 and 4.3

Jelly Bean

16, 17 and 18

4.4

KitKat

19

5.0

Lollipop

21

6.0

Marshmallow

23

TASK-10
write a simple Android Application which will print "Hello World! Using Eclipse".
Requirements:
JDK 1.6 Or Above
ANDROID SDK
ECLIPSE IDE
To Download Android SDK using following Link
https://developer.android.com/sdk/index.html

The first step is to create a simple Android Application using Eclipse IDE. Follow the option File
-> New -> Project
and finally select Android New Application wizard from the wizard list. Now name your
application as HelloWorld
using the wizard window as follows:
Next, follow the

instructions provided and keep all other entries as default till the final step. Once your project is
created successfully,
you will have following project screen:

Android Application(View)
Before you run your app, you should be aware of a few directories and files in the Android
project:

S.N.
1.

3
4
5
6

Folder, File & Description


src
This contains the .java source files for your project. By default, it includes an
MainActivity.java source file having an activity class that runs when your app is launched
using the app icon.
gen
This contains the .R file, a compiler-generated file that references all the resources found in
your project. You should not modify this file.
bin
This folder contains the Android package files .apk built by the ADT during the build
process and everything else needed to run an Android application.
res/drawable-hdpi
This is a directory for drawable objects that are designed for high-density screens.
res/layout
This is a directory for files that define your app's user interface.
res/values
This is a directory for other various XML files that contain a collection of resources, such
as strings and colors definitions.
AndroidManifest.xml
This is the manifest file which describes the fundamental characteristics of the app and
defines each of its components.

The Main Activity File


The main activity code is a Java file MainActivity.java. This is the actual application file which
ultimately getsconverted to a Dalvik executable and runs your application. Following is the
default code generated by the application wizard for Hello World! application:
MainActivity.java:
package com.example.helloworld;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.view.MenuItem;
import android.support.v4.app.NavUtils;
public class MainActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.activity_main, menu);
return true;

}
}
The activity_main.xml is a layout file available in res/layout directory, that is referenced by
your application when
building its interface. You will modify this file very frequently to change the layout of your
application. For your "Hello
World!" application, this file will have following content related to default layout:
activity_main.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextViewandroid:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="hello world"
tools:context=".MainActivity" />
</RelativeLayout>
Run on the Emulator
Whether you're using Eclipse or the command line, to run your app on the emulator you need to
first create an Android Virtual Device (AVD). An AVD is a device configuration for the Android
emulator that allows you to model different devices.
To create an AVD:
1. Launch the Android Virtual Device Manager:
In Eclipse, click Android Virtual Device Manager

from the toolbar.

2. In the Android Virtual Device Manager panel, click New.


3. Fill in the details for the AVD. Give it a name, a platform target, an SD card size, and a
skin (HVGA is default).
4. Click Create AVD.
5. Select the new AVD from the Android Virtual Device Manager and click Start.
6. After the emulator boots up, unlock the emulator screen.

Figure 1. The AVD Manager showing a few virtual devices.


To run the app from Eclipse:
1. Open one of your project's files and click Run

from the toolbar.

2. In the Run as window that appears, select Android Application and click OK.

TASK -10
Write an Android application program that accepts a name from the user and
displays the hello name to the user in response as output using Eclipse.
FrmActivity.java
(Activity JAVA Prog)
package com.example1.myapp;
import android.os.Bundle;
import android.app.Activity;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
public class FrmActivity extends Activity {
Button mButton;
EditText mEdit;
TextView mText;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_frm);
mButton = (Button)findViewById(R.id.button1);
mButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
mEdit = (EditText)findViewById(R.id.editText1);
mText = (TextView)findViewById(R.id.textView1);
mText.setText("Welcome "+mEdit.getText().toString()+"!");
}
});
}
}
activity_frm.xml (main.xml)
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context=".FrmActivity" >

<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/textView1"
android:layout_marginLeft="18dp"
android:layout_marginTop="28dp"
android:text="@string/empty"
android:textColor="@color/Green"
android:textSize="32sp" />
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginTop="102dp"
android:text="@string/Input"
android:textColor="@color/BLUE"
android:textColorHint="@color/BLUE"
android:textSize="24sp" />
<EditText
android:id="@+id/editText1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignTop="@+id/textView2"
android:layout_centerHorizontal="true"
android:background="#CCCCCC"
android:ems="10"
android:inputType="textPersonName" >
<requestFocus />
</EditText>
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignRight="@+id/editText1"
android:layout_below="@+id/textView2"
android:layout_marginRight="16dp"
android:layout_marginTop="17dp"

android:text="@string/sub"
android:textColor="@color/Green" />
</RelativeLayout>
Strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">MyApp</string>
<string name="action_settings">Settings</string>
<string name="hello_world">Hello world!</string>
<string name="empty">" "</string>
<string name="sub">Submit</string>
<string name="Input">Enter_name</string>
<color name="BLUE">#2372AC</color>
<color name="Green">#00ff00</color>
</resources>

You might also like