69
Android

Anroid Class Material

Embed Size (px)

Citation preview

Page 1: Anroid Class Material

Android

Page 2: Anroid Class Material

Topics• Smart phones• What Is Android?• Downloading and Installing Eclipse• Downloading and Installing the Android SDK• Exploring the Android SDK• Application: Hello World!• View Layouts• Android Widgets• Using Intents and the Phone Dialer

Page 3: Anroid Class Material

Smart Phones

• Smartphones combine the mobile phone with another stream of technology - the computer, which adds the ‘smart’ in smartphone.

MainFrame -> PC -> Laptops -> PDA -> Smartphone

• Like PDAs, smartphones can run applications such as organizers, games,and communications programs (e.g. email, browser).

• The smartphone’s goal, however, is not just to limit the number of devices you carry, but also to combine mobile phone and computing technologies in a synergistic way.

Page 4: Anroid Class Material

Mobile OS Structure

A mobile OS is a software platform on top of which other programs called application programs, can run on mobile devices such as PDA, cellular phones, smartphone and etc.

Low-Level Hardware, Manufacturer Device Drivers

Device Operating System Base, Kernel

OS Libraries

Applications

Page 5: Anroid Class Material

Mobile OS Platforms

There are many mobile operating systems. The followings demonstrate the most important ones:– Java ME Platform– Palm OS– Symbian OS– Linux OS– Windows Mobile OS– BlackBerry OS– iPhone OS– Google Android Platform

Page 6: Anroid Class Material

Symbian OS Structure

Hardware

Symbian OS Base- Kernel

Symbian OS Libraries

Servers

Application EnginesKVM

Page 7: Anroid Class Material

Embedded Linux OS

• It is a Real-Time Operating System (RTOS). It meets deadlines and switch context

• It has relatively a small footprint. Today, mobile phones can ship with a small memory. Thus, OS must not seek to occupy a large amount of available storage. It should have a small foot print. Theoretically, they deploy in a footprint of 1MB or less.

• It is open source. It has no cost for licensing.

• Examples: Motorola Mobile phones such as RAZR V8, RAZR V9, A1200 are based on MontaVista Linux.

Page 8: Anroid Class Material

Windows Mobile OS

• Windows Mobile is a compact operating system designed for mobile devices and based on Microsoft Win32.

• It is run on Pocket PCs, Smartphones and Portable media centers.

• It provides ultimate interoperability. Users with various requirements are able to manipulate their data.

Page 9: Anroid Class Material

iPhone OS

• iPhone OS is an operating system run on iPhone and iPod.

• It is based on Mach Kernel and Drawin core as Mac OS X.

• The Mac OS X kernel includes the following component:– Mach Kernel– BSD– I/O component– File Systems– Networking components

Page 10: Anroid Class Material

Topics• Smart phones• What Is Android?• Downloading and Installing Eclipse• Downloading and Installing the Android SDK• Exploring the Android SDK• Application: Hello World!• View Layouts• Android Widgets• Using Intents and the Phone Dialer

Page 11: Anroid Class Material

Background

• Software platform from Google and the Open Handset Alliance

• July 2005, Google acquired Android, Inc.• November 2007, Open Handset Alliance formed to develop

open standards for mobile devices• October 2008, Android available as open source• December 2008, 14 new members joined Android project• April 30, 2009: Official 1.5 Cupcake release• September 15, 2009: 1.6 SDK Donut release• October 26, 2009: 2.0 SDK Éclair release

– Updates to the Éclair release:• 2.0.1 on December 3, 2009• 2.1 on January 12, 2010

Page 12: Anroid Class Material

Features

• Reuse and replacement of components.• Dalvik virtual machine.• Integrated browser.• Optimized graphics.• SQLite.• Media support.• GSM Telephony.• Bluetooth, EDGE, 3G, and WiFi.• Camera, GPS, compass, and accelerometer.• Rich development environment.

Page 13: Anroid Class Material

Application Fundamentals

• Apps are written in Java• Bundled by Android Asset Packaging Tool• Every App runs its own Linux process• Each process has it’s own Java Virtual Machine• Each App is assigned a unique Linux user ID• Apps can share the same user ID to see each other’s files

Page 14: Anroid Class Material

Android Architecture

Page 15: Anroid Class Material

Android Architecture• Linux Kernel: Android relies on Linux for core system services

such as security, memory management, process management.

• Android Runtime: it provides a set of core libraries which supports most of the functionality in the core libraries of Java. The Android Virtual Machine known as Dalvik VM relies on the linux kernel for some underlying functionality such as threading,…

• Libraries: Android includes a set of C/C++ libraries. These libraries are exposed to developers through the Android application framework. They include media libraries, system C libraries, surface manager, 3D libraries, SQLite and etc.

• Application Framework: it provides an access layer to the framework APIs used by the core applications. It allows components to be used by the developers.

Page 16: Anroid Class Material

Challenges•CPU typically runs 500-600 Mhz

•RAM available to an App may only be a few megabytes

•Disk (flash) access is very slow

•Lifecycle - apps must pause/quit often, and restore to give the illusion that they are always running

•Typical screen may be HVGA (320x480) may be in portrait or landscape

•Very high DPI - small text may not be readable

•Touch resolution is very low (~25 pixel)

•Network access may be slow and (very) intermittent

Page 17: Anroid Class Material

Topics• Smart phones• What Is Android?• Downloading and Installing Eclipse• Downloading and Installing the Android SDK• Exploring the Android SDK• Application: Hello World!• View Layouts• Android Widgets• Using Intents and the Phone Dialer

Page 18: Anroid Class Material

Downloading and Installing Eclipse•Before downloading and installing Eclipse, make sure Java Runtime Environment (JRE) is downloaded and installed on the machine.

•Eclipse requires JRE to run – Download JDK (includes JRE) from www.oracle.com/technetwork/java/javase/downloads/index.html

•Download Eclipse from www.eclipse.org/downloads/

•Unzip the package to a folder. The editors executable is eclipse.exe.( There is no installation wizard)

•Create a shortcut for the eclipse.exe and copy it to the desktop

Page 19: Anroid Class Material

Topics• Smart phones• What Is Android?• Downloading and Installing Eclipse• Downloading and Installing the Android SDK• Exploring the Android SDK• Application: Hello World!• View Layouts• Android Widgets• Using Intents and the Phone Dialer

Page 20: Anroid Class Material

Downloading SDK

•Download the Android SDK from http://developer.android.com/sdk/index.html

•Extract it and note down the location.

•Add the SDK path to the Environment variable.

Page 21: Anroid Class Material

Installing ADT Plug in for Eclipse1. Start Eclipse, then select Help > Install New Software....

2. Click Add, in the top-right corner.

3. In the Add Repository dialog that appears, enter "ADT Plugin" for theName and the following URL for the Location:https://dl-ssl.google.com/android/eclipse/.

4. Click OK.

5. In the Available Software dialog, select the checkbox next to Developer Tools and click Next.

6. In the next window, you'll see a list of the tools to be downloaded. Click Next.

7. Read and accept the license agreements, then click Finish.

8. When the installation completes, restart Eclipse.

Page 22: Anroid Class Material

Configuring the ADT Plugin

1. Select Window > Preferences... to open the Preferences panel.

2. Select Android from the left panel.

3. For the SDK Location in the main panel, click Browse... and locate your downloaded SDK directory.

4. Click Apply, then OK.

Page 23: Anroid Class Material

Adding Components

1. From within Eclipse, select Window > Android SDK and AVD Manager.

2.

Page 24: Anroid Class Material

•Smart phones•What Is Android?•Downloading and Installing Eclipse•Downloading and Installing the Android SDK•Exploring the Android SDK•Application: Hello World!•View Layouts•Android Widgets•Using Intents and the Phone Dialer

Page 25: Anroid Class Material

What is in the Android SDKThe Android SDK consists of

1. Docs, Contains all of the accompanying Android documentation.

2. Samples Contains six sample applications that you can compile and test from within Eclipse.

3. Tools Contains all of the development, compilation, and debugging tools.

Page 26: Anroid Class Material

Tools in the Android SDK• The Android Emulator is used to run your applications

in a pseudo-Android environment.

• Android Debug Bridge or adb (adb.exe) allows you to issue commands to the Emulator.exe tool.

• MKSDCARD.exe is a tool if you are testing an application that will need to read / write files on SD Memory Card.

• DX.exe is the compiler of the Android SDK. When run against Java files, will create files with .dex extensions -Dalvik executable format.

Page 27: Anroid Class Material

•Smart phones•What Is Android?•Downloading and Installing Eclipse•Downloading and Installing the Android SDK•Exploring the Android SDK•Application: Hello World!•View Layouts•Android Widgets•Using Intents and the Phone Dialer

Page 28: Anroid Class Material

Creating an Android Project

Page 29: Anroid Class Material

Creating an Android Project

Name of the project file

Name of the Application

Name of the Package

Name of the Activity

Page 30: Anroid Class Material

Examining the Android-Created FilesRoot Directory : It is the home, or repository, for all of project files.

Manifest: XML file where global settings are made.

Library: A list of the Referenced Libraries. android.jar, the Android SDK

Res: project resources are held.

Drawable-***: contains actual image files that your application can use andreference.

Layout: Holds main.xml, that is referenced by the application when building its interface..

Assets: to hold raw asset files, audio files for streaming and animation assets

Src: contains all the source files for your project

Page 31: Anroid Class Material

Hello world – XML Based

package android_programmers_guide.HelloWorldText;

import android.app.Activity;import android.os.Bundle;

public class HelloWorldText extends Activity {

/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle icicle) {

super.onCreate(icicle);setContentView(R.layout.main);}

}

Page 32: Anroid Class Material

Hello world – XML Based

<?xml version="1.0" encoding="utf-8"?><LinearLayout

xmlns:android=http://schemas.android.com/apk/res/androidandroid:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent" >

<TextViewandroid:layout_width="fill_parent"android:layout_height="wrap_content"android:text="Hello World, HelloWorldText"

/></LinearLayout>

Page 33: Anroid Class Material

Hello world – Code Based

<?xml version="1.0" encoding="utf-8"?><LinearLayout

xmlns:android=http://schemas.android.com/apk/res/androidandroid:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent">

</LinearLayout>

Page 34: Anroid Class Material

Hello world – Code Based

package android_programmers_guide.HelloWorldText;import android.app.Activity;import android.os.Bundle;import android.widget.TextView;

public class HelloWorldText extends Activity {

/** Called when the activity is first created. */@Overridepublic void onCreate(Bundle icicle) {

TextView HelloWorldTextView = new TextView(this);HelloWorldTextView.setText("Hello World!");setContentView(HelloWorldTextView);

}}

Page 35: Anroid Class Material

Hello world – Using an Image

Example application that shows Hello world with an Image by

• XML Layout based UI.• Code based UI.

Page 36: Anroid Class Material

Topics• What Is Android?• Downloading and Installing Eclipse• Downloading and Installing the Android SDK• Exploring the Android SDK• Application: Hello World!• View Layouts• Android Widgets• Using Intents and the Phone Dialer

Page 37: Anroid Class Material

Layouts

Controls how Views are laid out

• LinearLayout : single row or column• RelativeLayout : relative to other Views• TableLayout : rows and columns• AbsoluteLayout : < x, y > coordinates

Page 38: Anroid Class Material

Linear Layout

• All elements are arranged in a descending column from top to bottom or left to right.

• Each element can have gravity and weight properties that denote how they dynamically grow and shrink to fill space.

• Elements arrange themselves in a row or column notation based on the android:orientation parameter.

Page 39: Anroid Class Material

Linear Layout - Example

• All elements are arranged in a descending column from top to bottom or left to right.

• Each element can have gravity and weight properties that denote how they dynamically grow and shrink to fill space.

• Elements arrange themselves in a row or column notation based on the android:orientation parameter.

Page 40: Anroid Class Material

Linear Layout

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"android:orientation="vertical"android:layout_width="fill_parent"android:layout_height="fill_parent"><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element One"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element Two"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element Three"/></LinearLayout>

Page 41: Anroid Class Material

Relative Layout

• Each child element is laid out in relation to other child elements.

• Relationships can be established so that children will start themselves where a previous child ends.

• Children can relate only to elements that are• listed before them.• Note that IDs are required so that widgets can reference

each other.

Page 42: Anroid Class Material

Relative Layout - Example<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"android:layout_height="fill_parent">

<TextViewandroid:id="@+id/EL01"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element One"

/><TextView

android:id="@+id/EL02"android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element Two"android:layout_below="@id/EL01"

/><TextView

android:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element Three"android:layout_toRight="@id/EL02"

/></RelativeLayout>

Page 43: Anroid Class Material

Absolute Layout

• Each child must be given a specific location within the bounds of the parent layout object.

• The Absolute Layout object is probably the easiest tobuild and visualize but the hardest to migrate to a new device

or screen size.

Page 44: Anroid Class Material

Absolute Layout - Example<AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent">

<TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element One"/>

<TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element Two"android:layout_x="30px"android:layout_y="30px"/>

<TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element Three"android:layout_x="50px"android:layout_y="50px“/></AbsoluteLayout>

Page 45: Anroid Class Material

Table Layout

• Table Layout is a layout object that allows you to specify table rows.

• Android tries to arrange each of the child elements into the correct row and columns.

Page 46: Anroid Class Material

Table Layout - Example<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="fill_parent"android:layout_height="fill_parent"><TableRow>

<TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element One A"/><TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element One B"/>

</TableRow><TableRow>

<TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element Two A"/>

<TextViewandroid:layout_width="wrap_content"android:layout_height="wrap_content"android:text="Element Two B"/>

</TableRow></TableLayout>

Page 47: Anroid Class Material

Topics• What Is Android?• Downloading and Installing Eclipse• Downloading and Installing the Android SDK• Exploring the Android SDK• Application: Hello World!• View Layouts• Android Widgets• Using Intents and the Phone Dialer

Page 48: Anroid Class Material

Labels• The simplest widget is the label, referred to in Android as a

TextView.• Bits of text not editable directly by users, used to identify

adjacent widgets (e.g., a "Name:" label before a field where one fills in a name).

<?xml version="1.0" encoding="utf-8"?><TextView xmlns:android="http://schemas.android.com/apk/res/android"

android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="You were expecting something profound?"

/>

Page 49: Anroid Class Material

Button<Button

android:id="@+id/btn"android:layout_width="fill_parent"android:layout_height="wrap_content"android:text=“Button“

/>

import android.view.View;import android.widget.Button;

public class Helloworld extends Activity implements View.OnClickListener{

Button btn; btn = (Button)findViewById(R.id.ok); btn.setOnClickListener(this);}

public void onClick(View view){ btn.setText("New Text");

}

Page 50: Anroid Class Material

Check Box<CheckBox android:id="@+id/testCheckBox"

android:layout_width="fill_parent"android:layout_height="wrap_content"android:text="This is the test CheckBox"

/>

import android.widget.CheckBox;

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main ); CheckBox checkbox; checkbox = (CheckBox)findViewById(R.id.testCheckBox); checkbox.setOnClickListener(this);} public void onClick(View v){

}

Page 51: Anroid Class Material

Edit Text<EditText android:id="@+id/testEditText"

android:layout_width="fill_parent"android:layout_height="wrap_content"

/>

import android.widget.EditText;

public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main );}

Page 52: Anroid Class Material

Radio Button

<RadioGroup android:id="@+id/testRadioGroup" android:layout_width="fill_parent"android:layout_height="wrap_content" >

<RadioButtonandroid:text="Radio 1"android:id="@+id/radio1"/>

<RadioButtonandroid:text="Radio 2"android:id="@+id/radio2" /></RadioGroup>

Page 53: Anroid Class Material

Spinner Control<Spinner android:id="@+id/testSpinner"android:layout_width="fill_parent"android:layout_height="wrap_content"/>

public class Helloworld extends Activity{ boolean value;

@Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main ); final Spinner spinner = (Spinner) findViewById(R.id.testSpinner); ArrayAdapter<String> adapter = new ArrayAdapter<String>(this,android.R.layout.simple_spinner_item,Months); adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); spinner.setAdapter(adapter); } static final String[] Months = new String[] { "January","February","March","April","May","June","July","August", "September","October","November","December" };}

Page 54: Anroid Class Material

Menupublic class Helloworld extends Activity{boolean value;

/** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main ); }

@Override public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); menu.add(0, 0,0, "AutoComplete"); menu.add(0, 1,0, "Button"); menu.add(0, 2,0, "CheckBox"); menu.add(0, 3,0, "EditText"); menu.add(0, 4,0, "RadioGroup"); menu.add(0, 5,0, "Spinner");

return true; } }

Page 55: Anroid Class Material

Topics• Smart phones• What Is Android?• Downloading and Installing Eclipse• Downloading and Installing the Android SDK• Exploring the Android SDK• Application: Hello World!• View Layouts• Android Widgets• Using Intents and the Phone Dialer

Page 56: Anroid Class Material

What are Intents?• An Intent is Android’s method for relaying certain information

from one Activity to another.• You can think of an Intent as a message passed between

Activities.

Intents are broken up into two main categories:– Activity Action Intents : Intents used to call Activities

outside of your application. Only one Activity can handle the Intent.

– Broadcast Intents : Intents that are sent out for multiple Activities to handle. An example of a Broadcast Intent would be a message sent out by Android about the current battery level. Any Activity can process this Intent and react accordingly.

Page 57: Anroid Class Material

Broadcast Intents

Broadcast Intent Message

CALL_FORWARDING_STATE_CHANGED_ACTION The phone’s call forwarding state has changed

CAMERA_BUTTON_ACTION The camera button has been pressed

DATA_ACTIVITY_STATE_CHANGED_ACTION The device’s data activity state has changed

DATA_CONNECTION_STATE_CHANGED_ACTION There has been a change in the data connection state

DATE_CHANGED_ACTION The phone’s system date has changed

FOTA_CANCEL_ACTION Cancel pending system update downloads

FOTA_INSTALL_ACTION An update has been downloaded and must be installed immediately (sent by the system)

MEDIA_BAD_REMOVAL_ACTION Sent when an SD Memory Card was removed but unsuccessfully unmounted from the system

MESSAGE_WAITING_STATE_CHANGED The “message waiting” state on the phone has changed

PACKAGE_ADDED_ACTION Sent when a new package has been installed on the device

SCREEN_OFF_ACTION The screen has been shut off (sent by the device)

SIGNAL_STRENGTH_CHANGED_ACTION The signal strength has changed

SIM_STATE_CHANGED_ACTION The state of the SIM card has changed

TIME_TICK_ACTION The current time has changed

WALLPAPER_CHANGED_ACTION The device’s wallpaper has been changed

Page 58: Anroid Class Material

Activity Intents

Activity Intent Message

ADD_SHORTCUT_ACTION Add a function shortcut to the Android Home Screen

ALL_APPS_ACTION List all the applications available on the device

BUG_REPORT_ACTION Open the Bug Reporting Activity

CALL_ACTION Answer an incoming call

DELETE_ACTION Delete the specified data

DIAL_ACTION Open the Dial Activity and dial the specified number

EDIT_ACTION Provide editable access to the supplied data

EMERGENCY_DIAL_ACTION Dial an emergency number

FACTORY_TEST_ACTION Retrieve factory test settings

GET_CONTENT_ACTION Select and return specified data

INSERT_ACTION Insert an empty item

MAIN_ACTION Establish the Activity start point

PICK_ACTION Pick an item and return the selection

PICK_ACTIVITY_ACTION Pick a given Activity (returns a class)

RUN_ACTION Execute the given data

Page 59: Anroid Class Material

Example - Using the Dialerpackage android_programmers_guide.AndroidPhoneDialer;

import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.net.Uri;

public class AndroidPhoneDialer extends Activity {

@Overridepublic void onCreate(Bundle icicle) {

super.onCreate(icicle);setContentView(R.layout.main);

Intent DialIntent = newIntent(Intent.DIAL_ACTION,Uri.parse("tel:5551212"));

/** Use NEW_TASK_LAUNCH to launch the Dialer Activity */DialIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH );/** Finally start the Activity */startActivity(DialIntent);

}}

Page 60: Anroid Class Material

Example – Calling a Numberimport android.content.Intent;import android.os.Bundle;import android.net.Uri;

public class AndroidPhoneDialer extends Activity {

public void onCreate(Bundle icicle) {

super.onCreate(icicle);setContentView(R.layout.main);

Intent CallIntent = new Intent(Intent.CALL_ACTION,Uri.parse("tel:5551212"));

/** Use NEW_TASK_LAUNCH to launch the Call Activity */CallIntent.setLaunchFlags(Intent.NEW_TASK_LAUNCH );/** Finally start the Activity */startActivity(CallIntent);

}}

Page 61: Anroid Class Material

Activity Permissions• Most Activity Action Intents fall into the category of

requiring that the proper permission be set before Android will allow the action.

• Android just needs to make sure that only Activities with the correct credentials be allowed to perform actions with Activities that are outside of their base.

Permissions:● ACCESS_ASSISTED_GPS ● INTERNAL_SYSTEM_WINDOW● ACCESS_CELL_ID ● RAISED_THREAD_PRIORITY● ACCESS_GPS ● READ_CONTACTS● ACCESS_LOCATION ● READ_FRAME_BUFFER● ACCESS_SURFACE_FLINGER ● RECEIVE_BOOT_COMPLETED● ADD_SYSTEM_SERVICE ● RECEIVE_SMS● BROADCAST_PACKAGE_REMOVED ● RECEIVE_WAP_PUSH● BROADCAST_STICKY ● RUN_INSTRUMENTATION● CALL_PHONE ● SET_ACTIVITY_WATCHER● CHANGE_COMPONENT_ENABLED_STATE ● SIGNAL_PERSISTENT_PROCESSES● SET_PREFERRED_APPLICATIONS ● DELETE_PACKAGES

Page 62: Anroid Class Material

Application Lifecycle

• Android Applications have no control over their own life cycle.

• Android aggressively manages its resource doing what ever it takes to ensure that the device remains responsive.

• This means that processes will be killed without warning if necessary to free resources for higher priority applications.

Page 63: Anroid Class Material

The state of each Activity is determined by its position on the Activity stack, a last-in–first-out collection of all the currently running Activities.

When a new Activity starts, the current foreground screen ismoved to the top of the stack.

If the user navigates back using the Back button, or the foreground Activity is closed, the next Activityon the stack moves upand becomes active.

Activity states

Page 64: Anroid Class Material

State transitions are nondeterministic and are handled entirely by the Android memory manager.

Android will start by closing applications that contain inactive Activities, followed by those that are stopped, and in extreme cases, it will remove those that are paused.

For seamless user experience, transitions between these states should be invisible to the user. It is important to save all UI state changes and persist all data when an Activity is paused or stopped. Once an Activity does become active, it should restore those saved values.

Active Paused Stopped Inactive

Activity states

Page 65: Anroid Class Material

State Changes

Page 66: Anroid Class Material

What makes an Android ApplicationAndroid Application consists of loosely coupled components

bound using a project Manifest.Building blocks of Android Application are:

1. Activities2. Services3. Content Providers4. Intents5. Broadcast Receivers6. Notifications

Page 67: Anroid Class Material

What makes an Android ApplicationActivities:• Applications presentation layer.• Every screen in the application will be an extension of

the Activity class.• Activities use views to form GUI.• Activities are equivalent to Forms in Desktop world.

Services:• These components run invisibly.• They are used to perform regular processing that needs

to continue even when the application Activities aren’t visible.

Page 68: Anroid Class Material

What makes an Android ApplicationContent Providers:• A sharable database.• Preferred way of sharing data across process

boundaries.• It is possible to configure a content provider to permit

access from other applications.• Use Content providers exposed by other applications to

access their stored data.Intents:• Message passing Framework.• Broadcast message system wide or to a target activity or

service.

Page 69: Anroid Class Material

What makes an Android ApplicationBroadcast consumers:• Intent Broadcast consumers• By creating and registering a Broadcast receiver, an

application can listen for broadcast intents.

Notifications:• Notifies user without stealing focus or interrupting their

current activists.