Unit - 1
Android OS
Prof. Shardul Agravat
Topics Covered
• What is Android?
• Android versions and its feature set
• Advantages and Disadvantages of Android OS
• The Android architecture
• The various Android devices on the market
• The Android Market application store
• How to obtain the tools and SDK for developing Android applications
• How to develop your first Android application
• Android APIs
What is Android?
• Android is a mobile operating system that is based on a modified version of
Linux.
• It was originally developed by a startup of the same name, Android, Inc.
• In 2005, as part of its strategy to enter the mobile space, Google purchased
Android and took over its development work (as well as its development team).
• Google wanted Android to be open and free; hence, most of the Android code
was released under the open source Apache License, which means that anyone
who wants to use Android can do so by downloading the full Android source
code.
Android Versions
Features of Android
• Storage • Hardware support
• Connectivity • Multi-touch
• Messaging • Multi-tasking
• Web browser • Flash support
• Media support • Tethering
Advantages of Android OS
• Supports 2D and 3D Graphics
• Supports different languages
• Supports various video formats
• Video Calling is also supported
• Open source framework
• Better notification system
• Less chance of crashing applications
• Secure and stable
Disadvantages of Android OS
• Slow response
• Heating up the device due to more processing
Architecture of Android
Architecture of Android
The Android OS is roughly divided into five sections
in four main layers:
• Linux kernel
• Libraries
• Android runtime
• Application framework
• Applications
Installing Android
JAVA JDK The Android SDK makes use of the
Java SE Development Kit (JDK). If your
computer does not have the JDK installed, you
should start by downloading it from
www.oracle.com/technetwork/java/javase/do
wnloads/index.html and installing it prior to
moving to the next section.
Android SDK
You can download the Android SDK from http://developer.android.com/sdk/index.html
Installing the Android SDK Tools
Configuring the Android SDK Manager
Components of Android Application
• Fragments: Represents a portion of user interface in an Activity.
• Views: UI elements that are drawn on-screen including buttons, lists
forms etc.
• Layouts: View hierarchies that control screen format and appearance of
the views.
• Intents: Messages wiring components together.
• Resources: External elements, such as strings, constants and drawable
pictures.
• Manifest: Configuration file for the application.
Folder, File & Description
• Java: 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.
• 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 colours
definitions.
• AndroidManifest.xml: This is the manifest file which
describes the fundamental characteristics of the app and
defines each of its components.
• Build.gradle: This is an auto generated file which contains
compileSdkVersion, buildToolsVersion, applicationId,
minSdkVersion, targetSdkVersion, versionCode and
versionName
The Main Activity File MainActivity.java
package com.example.helloworld;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
The Manifest File manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.tutorialspoint7.myapplication">
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
The Strings File strings.xml
<resources>
<string name="app_name">HelloWorld</string>
<string name="hello_world">Hello world!</string>
<string name="menu_settings">Settings</string>
<string
name="title_activity_main">MainActivity</string>
</resources>
The Layout File 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" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
Running the Application
Application Components
• Activities: They dictate the UI and handle the user interaction to the smart
phone screen.
– An activity is implemented as a subclass of Activity class as follows −
public class MainActivity extends Activity
{
• Services: They handle background processing associated with an
application.
– A service is implemented as a subclass of Service class as follows −
public class MyService extends Service
{
}
• Broadcast Receivers: They handle communication between Android OS
and applications.
public class MyReceiver extends BroadcastReceiver
{
public void onReceive(context,intent)
{
}
}
• Content Providers: They handle data and database management issues.
public class MyContentProvider extends ContentProvider
{
public void onCreate()
{
}
}
Android APIs
• android.util : Provides utility classes such as containers,
string formatters, XML parsers etc.
• android.os : Provides basic operating system services.
• android.graphics : Provides support for graphics classes
such as canvases, colors, shapes etc.
• android.text : Provides text processing tools for
displaying and parsing text.
Android APIs
• android.database : Provides classes to work with databases.
• android.content : It is used to manage data access and
dealing with resources and content providers.
• android.view : Views are the core user interface class. It is
used to design UI.
• com.google.android.maps : A high level API used to
integrate maps in your application.
Android APIs
• android.app : It provides Activity and service related APIs to
create android applications.
• android.telephony : This API gives access to interact with the
device’s phone stack. It allows you to make, receive calls and
SMSes.
• android.webkit : It allows you to access web based content,
manage cookies and embed web browser activities in your
application.
Any Questions?