Android Development Training Session # 1 + Session # 2: Created By: Muhammad Tayyab

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 23

ANDROID DEVELOPMENT TRAINING SESSION # 1 + SESSION # 2

Created By: Muhammad Tayyab

Introduction to Android Development

What is Android? Features


Application framework Dalvik virtual machine Integrated browser Optimized graphics SQLite Media support (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF) GSM Telephony (hardware dependent) Bluetooth, EDGE, 3G, and WiFi (hardware dependent) Camera, GPS, compass, and accelerometer (hardware dependent) Rich development environment

Android Architecture

Getting Started

Setting up Android Development Environment Using Android Emulator Creating first Hello World Application
Components

of Android application Running Application on Emulator Debugging Android Application


Android Development Tools Using DDMS

Application Fundamentals

Application Components
Activities
Services Broadcast

Receivers Content Providers


Intents Activities and Tasks Process and Threads


Remote

Procedure Calls

Activities

An activity presents a visual user interface for one focused endeavor the user can undertake. Activity is implemented as a subclass of the Activity base class. The visual content of the window is provided by a hierarchy of views.
objects

derived from the base View class.

A view hierarchy is placed within an activity's window by the Activity.setContentView() method.

Services

A Service does not have a visual interface and runs in the background. Each service extends the Service base class. It's possible to connect to an ongoing service and communicate it through the interface exposed by that service. Services run in the main thread of the application process.

Broadcast Receivers

A broadcast receiver receive and react to broadcast announcements. All receivers extend the BroadcastReceiver base class. Many broadcasts originate in system code. Broadcast receivers do not display a user interface but they can start an activity or alert user.

Content Providers

A content provider makes a specific set of the application's data available to other applications. All content providers extends the ContentProvider base class. Content Providers are accessed through ContentResolver object. Content Providers and Content Resolvers enable inter-process communication (IPC)

Intents

Intents are Asynchronous messages used to convey a request or message. An intent is an object of Intent class that holds the content of the message. Activities, Services and Broadcast Receivers are activated through Intents. Intent can contain

Component name Action Data Category Extras Flags

Activities and Tasks

An activity presents a visual user interface for one focused endeavor the user can undertake. Task is what the user experiences as an application. Task is a group of related activities, arranged in a stack. The activity at the top of the stack is one that's currently running. All the activities in a task move together as a unit.

Process and Threads

Android starts a Linux process for each application by default. By default, all components of the application run in main thread of applications process. You can spawn separate threads for long operations. Threads are created in code using standard Java Thread objects

Remote Procedure Calls

Android has a lightweight mechanism for remote procedure calls (RPCs). An RPC interface can include only methods. All methods are executed synchronously. RPC Interface id declared using IDL and Java interface definition is generated by aidl tool.

Remote Procedure Calls

Application Fundamentals 2

Component Lifecycles
Activity

Lifecycle Service Lifecycle Broadcast receiver Lifecycle Process Lifecycle

Android Security Model

Activity Lifecycle

An activity has essentially three states


Active or Running Paused Stopped

Activity Lifetime
Entire Lifetime [onCreate() to onDestroy()] Visible Lifetime [onStart() to onStop()] Foreground Lifetime [onResume() to onPause()]

An implementation of any activity lifecycle method should always first call the superclass version

Activity Lifecycle

Service Lifecycle

A service can be used in two ways


stopService() bindService() unbindService()
startService()

Service Lifetime
Entire

Lifetime [onCreate() to onDestroy()] Active Lifetime [onStart()]

The onCreate() and onDestroy() methods are called for all services. onStart() is called only for services started by startService().

Service Lifecycle

Broadcast receiver Lifecycle

A broadcast receiver has single callback method


onReceive()

The lifetime of a broadcast receiver is only during the execution of onReceive() method. A process with an active broadcast receiver is protected from being killed.

Process Lifecycle

The Android system tries to maintain an application process for as long as possible. Android kills the old processes based on importance when memory runs low. There are five levels in the hierarchy according to importance
Foreground process Visible Process Service Process Background Process Empty Process

Android Security Model

Each Android Application runs in its own process which is a secure sandbox. Each Android package file installed on the device is given its own unique Linux user ID. The permissions required by an application are declared statically in that application. All Android applications must be signed. Any data stored by an application will be assigned that application's user ID, and not normally accessible to other packages.

Android Security Model

Permissions required by application are declared in application manifest file.

<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.android.app.myapp" > <uses-permission android:name="android.permission.RECEIVE_SMS" /> </manifest>


Activity Permissions

Permissions on components

Service Permissions Broadcast Receiver Permissions

ContentProvider Permissions

URI Permissions

You might also like