An Introduction to Android Application Development...Programming C++ Languages Android Android Debug...

12
An Introduction to Android Application Development Serdar Akın, Haluk Tüfekçi ARDIC ARGE – http://www.ardictech.com April 2011

Transcript of An Introduction to Android Application Development...Programming C++ Languages Android Android Debug...

Page 1: An Introduction to Android Application Development...Programming C++ Languages Android Android Debug Software Development Kit System (SDK) Development Environment Dalvik Cross Assembler

An Introduction to Android Application Development

Serdar Akın, Haluk Tüfekçi

ARDIC ARGE – http://www.ardictech.com

April 2011

Page 2: An Introduction to Android Application Development...Programming C++ Languages Android Android Debug Software Development Kit System (SDK) Development Environment Dalvik Cross Assembler

Programming Languages

Android Software Development Kit (SDK)

Development Environment

Dalvik Cross Assembler

Integrated Development Environment

Java (Officially supported)

C (Android NDK

Needed)

Operating System

Class Library

C++ (Android NDK

Needed)

Android Debug Bridge (adb)

Dalvik Debug Monitor Service

(ddms)

Android Emulator

Documentation Sample Codes System Images

Computing System

Native Development

Kit (NDK)

USB Driver (OEM USB drivers may be installed)

Ubuntu

Galileo

Java Development

Tools

Java Development

Kit 5 or 6

Android Development Tools Plugin

Page 3: An Introduction to Android Application Development...Programming C++ Languages Android Android Debug Software Development Kit System (SDK) Development Environment Dalvik Cross Assembler

Android Device

Android Development Environment

Environments

Process Man.

Memory Man.

Drivers, HAL

Security

Inter-process

Communication

Accessible

through JNI,

C/C++ Libraries,

UI, Graphics,

Media

Optimized

virtual machine,

Java Core

Libraries

Application Life

Cycle,

API,

Managers

Built-In

Applications

User

Applications

Eclipse

Android SDK

Hello,

World

APPLICATIONS

APPLICATION FRAMEWORK

ANDROID RUNTIME LIBRARIES

LINUX KERNEL

Display Driver

Keypad Driver WiFi Driver

Camera Driver Flash Memory

Driver

Audio Driver

Binder (IPC)

Driver

Power

Management

Java Core

Libraries

Dalvik Virtual

Machine

Surface

Manager

OpenGL|ES FreeType

Media

Framework SQLite

WebKit

SGL (2D

graphics) SSL bionic

Activity

Manager

Window

Manager

Content

Providers View Systems

Package

Manager

Telephony

Manager

Resource

Manager

Location

Manager Notification

Manager

Home Contacts Phone Browser …

Page 4: An Introduction to Android Application Development...Programming C++ Languages Android Android Debug Software Development Kit System (SDK) Development Environment Dalvik Cross Assembler

Application Framework

Activity Manager Application lifecycle Navigation

View Manager Programmable controls List, Grid, Textbox, Button, Embedded web browser

Resource Manager Localized strings Graphics Layout files

Notification Manager Custom alerts for end user

Content Providers Access data Share data

Package Manager Application Installation

Window Manager Screen organization Surface allocation for applications

Page 5: An Introduction to Android Application Development...Programming C++ Languages Android Android Debug Software Development Kit System (SDK) Development Environment Dalvik Cross Assembler

Hello, World

package com.google.android.HelloWorldActivity;

import android.app.Activity;

import android.os.Bundle;

public class HelloWorldActivity extends Activity {

public HelloWorldActivity() {

}

@Override

public void onCreate(Bundle icicle) {

super.onCreate(icicle);

setContentView(R.layout.helloworld_activity);

}

}

Page 6: An Introduction to Android Application Development...Programming C++ Languages Android Android Debug Software Development Kit System (SDK) Development Environment Dalvik Cross Assembler

Application Structures

Activity • A single, focused screen that the user can do

Intent • Intents are used for inter-communication among activities

or services • An intent is a data structure that stores a message

Broadcast Receiver

• A broadcast receiver triggers an intent to start an application

Service • Services run in the background for an indefinite period of

time • They have no user interface interaction

Content Provider

• A content provider is an interface to store and retrieve data and make it accessible to all applications

Resource • Externalization of strings and graphics

Page 7: An Introduction to Android Application Development...Programming C++ Languages Android Android Debug Software Development Kit System (SDK) Development Environment Dalvik Cross Assembler

Application Lifecycle

Activity starts

onCreate()

onStart()

onResume()

onRestart()

onPause()

onDestroy()

onStop()

Activity is running

Activity is shut down

User navigates back to the activity

Process is killed

The activity comes to the foreground

The activity comes to the foreground

Other applications need memory

Another activity comes in front of the

activity

The activity is no longer visible

Page 8: An Introduction to Android Application Development...Programming C++ Languages Android Android Debug Software Development Kit System (SDK) Development Environment Dalvik Cross Assembler

Views and Layouts

Parent Layout

Child Layout

Child Layout

Text Box

Button

Label

Child Layout

Text Box

Page 9: An Introduction to Android Application Development...Programming C++ Languages Android Android Debug Software Development Kit System (SDK) Development Environment Dalvik Cross Assembler

Layouts

* Absolute Layout is deprecated

Linear Layout • Vertical • Horizontal

Relative Layout Table Layout Frame Layout

Page 10: An Introduction to Android Application Development...Programming C++ Languages Android Android Debug Software Development Kit System (SDK) Development Environment Dalvik Cross Assembler

View Examples

GridView TabView MapView WebView

Page 11: An Introduction to Android Application Development...Programming C++ Languages Android Android Debug Software Development Kit System (SDK) Development Environment Dalvik Cross Assembler

Key points In Android Application Development

Performance and battery life is important in mobile devices

Recycle java objects

Avoid floating point arithmetic

Use efficient data format and parser

Reduce transferred data size, gzip text data

Keep memory small in order not to be killed

Services

Do not use services as daemons

Start them with AlarmManager only when device is awake

Use receivers to awaken services

Check battery life and do not run heavy jobs if battery is critical