SlideShare una empresa de Scribd logo
1 de 319
Android Application Development
Basic Training

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.

Ver1.02(01)
About usage of this Textbook
・ This textbook is licensed under the Creative Commons License BY-NC-SA
4.0. It is prohibited to use this material for business use otherwise you are
OESF member or OESF education consortium member.
・This training program, includes entire of training materials, will be
provided without any guarantee from OESF. OESF has no responsibility if
it occurred damages or legal violation behaviors which be caused of using
or misusing any content or detail information of this course.

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
Purpose of Training
• Equip the necessary knowledge for developing
application based on Android.
–
–
–
–

The functions provided by Android
Environment development
The usage of Development Tools
How to implement/debug the Application

• Experience application development through practice
exercises.

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
Training Schedule
• The 1st day
–
–
–
–

Chapter 1 :
Chapter 2 :
Chapter 3 :
Chapter 4 :

What is Android?
The architecture of Android Application
Environment development preparation
Tutorial

• The 2nd day
– Chapter 5 : Practice exercises
– Chapter 6 : Training summarize

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
Skill requirement to attend training course
• Have experience in Java
– Actually use Java to do programming in practice exercises in
the 2nd day.
– Have understanding of basic Java language specification.

• Have experience in using Eclipse
– Using Eclipse to practice exercises.

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1. What is Android?

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
Chapter 1: Overview
•
•
•
•
•
•

What is Android?
Why has Android attracted attention?
What can you do with Android?
Android from the technical aspect
Application development environment
How to distribute Applications?

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.1. What is Android?
• Android is
– Platform for Mobile devices
– Mainly used as Platform for Mobile phones

• The history of Android
Date

Content

10/2003

Android Company established

08/2005

Google bought Android Company

11/2007

Open Handset Alliance (OHA) established
Development Tool Android SDK 1.0 released

10/2008

Started to sell loading Android- Smart Phone 「T-Mobile G1」 in the world

04/2009

Development Tool Android SDK 1.5r1 released

05/2009

Development Tools Android SDK 1.5r2 released

07/2009

NTT Docomo started to sell Android Mobile 「HT-03A」 in Japan
Development Tool Android SDK 1.5r3 published
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.1. What is Android?
• The history of Android (Continue)
Date

Content

09/2009

Development Tool Android SDK 1.6 published

10/2009

Development Tool Android SDK 2.0 published

01/2010

Development Tool Android SDK 2.1 published

05/2010

Development Tool Android SDK 2.2 published

12/2010

Development Tool Android SDK 2.3 published (Gingerbread)

02/2011

Development Tool Android SDK 2.3.3 published
Development Tool Android SDK 3.0 published (Honeycomb)

This material is licensedEmbedded Creative Commons License BY-NC-SA 4.0.
Copyright 2009, Open under the Software Foundation, All rights reserved

9
1.1. What is Android?
• The main organizations related to Android
Organization Name

Overview

Open Handset Alliance
(OHA)

• This organization was established to promote popularization
of Android. Organize the activities of compatible
handsets/software development and services popularization.
• Android specifications settlement, deliverables control are
done by the OHA.
• 71 companies joined (until 05/2010) such as T-mobile (USA),
Motorola (USA), NTT Docomo (Japan), etc…
• http://www.openhandsetalliance.com/index.html

Open Embedded
Software Foundation
(OESF)

• This organization was established to develop and popularize
the common framework, platform for Android based
Embedded System.
• Working groups that are organized according to business
fields take the lead in implementing activities.
• 75 companies joined (until 05/2010)
• http://www.oesf.jp
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.2. Why has Android attracted attention?
• At the present, Android has attracted a lot of attention
– How much attention has it attracted?
• Android based hardware are being continuously launched to the
market.

Hardware

Overview

Mobile Phone

05/2009 NTT Docomo launched HT-03A (HTC Magic)
06/2009 HTC (Taiwan) launched HTC Hero
07/2009 T-Mobile myTouch 3G was on sale
01/2010 Google NEXUS ONE was on sale
04/2010 NTT Docomo Xperia was on sale

Media Player

Creative Zii EGG was on sale
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.2. Why has Android attracted attention?
• At the present, Android has attracted a lot of
attention.
– How much attention has it attracted?
• The number of web search about Android from the second haft of
2008 has been increasing. (Google Trend Research)
■ Major Events
A: T-Mobile G1 on sale
Android Market opened
B: OHA released Android SDK 2.0
C: Google Nexus One on sale
D: Small size version of Sony Ericsson
Xperia X10 on sale
E: Microsoft criticized for patent
infringement of Android
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.2. Why has Android attracted attention?
• There are 4 reasons why Android receives much
attention
1. Android is available for free, which is expected to reduce
cost for development platform.
2. Everyone can get Development Tools, Technical
documents and Source code in free.
3. The training cost is low if you know the Java SE.
4. Being deployed in embedded development field besides
Mobile Phone.

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.2. Why has Android attracted attention?
• Android is available for free, which is expected to
reduce cost for development platform.
– Expense for development platform is expected to reduce by
adopting Android platform.
※Development software combined with hardware, such as Driver, is
necessary.
Reduced cost

Application Development Fee
Platform Development Fee

Hardware Development Fee

Before use Android

After use Android

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.2. Why has Android attracted attention?
• Everyone can get Development Tools, Technical
documents and source code in free
– Under Apache License 2.0, Android’s documents, source
code have been published openly.
• The source of Proprietary modules such as driver, GoogleMapsAPI is
not provided.

– Development Tools are freely received from OHA.

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.2. Why has Android attracted attention?
• The training cost is low if you know the Java SE
– Because Android Application can be developed by Java SE
and Eclipse:
• It is unnecessary for learning development language if you know
Java language.
• The cost of learning how to use Development Tools is low for the
developer who has used Eclipse.

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.2. Why has Android attracted attention?
• Being deployed in embedded development field
besides Mobile Phone
– Besides Mobile phone, the utilization on various equipments
is being researched and developed
• Besides Mobile phone, some hardware which Android has been
transplanted into are:
– Net book
– Navigation System (Car Navi, etc.)
– TV Recorder (Record/play Digital broadcast)
– Other digital home appliances
» Be exhibited many times in the Embedded System
development technology Expo (ESEC2010)

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.3. What can you do with Android?
• Developer can create the applications that using the
following functions provided by Android
– View Website by Full browser
– Drawing 2D/3D Graphic
– Show/Play sound, image, still media
• Corresponding format (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF)

–
–
–
–
–
–

Voice call by GSM (2G), 3G
Data transmission by Bluetooth, EDGE, WiFi
Camera (still image/ video)
GPS
Various sensors
Data storage by SQLite
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.3. What can you do with Android?
• Sensor devices that can be controlled by Android
#

Sensor Name

Overview

1 Acceleration sensor

Detect acceleration

2 Tilt sensor

Detect azimuth, inclination (the above and below slope of
horizontal condition), rotation angle (the left and right
slope of horizontal condition)

3 Temperature sensor Detect temperature
4 Magnetic sensor

Detect magnetic

5 Light sensor

Detect light

6 Approach sensor

Detect the distance between objects

7 Gyroscope

Detect angular velocity

8 Pressure sensor

Detect the pressure put on real machine

※ Need the hardware when using sensors
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.3. What can you do with Android?
• Introduce Android applications

Web Browser

Telephone

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.

Google Maps
1.3. What can you do with Android?
– Using Web Browser
1.

View weather information
– Use Google Weather API to view
weather information
①

– Input Japanese (IME)
2.

Simeji
– Software keyboard allows Flick input

※ Flick input is a method that input to chose character
by slide the key of software keyboard

②
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.3. What can you do with Android?
– Using sensors
3.

4.

Google Sky Map
– Use inclination sensor and
acceleration sensor to view the
night sky in the direction toward
the terminal
Labyrinth lite
– The game uses inclination sensor

③

– Using camera
5.

Layer
– Browser displays the digital
information of the reality picture
taken by camera
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.

④

⑤
1.4. Android from the technical aspect
• The execution environment for Android applications
– Android applications run on Android run-time virtual
machine
– Linux has adopted as Android run-time platform, the
applications run on Linux
Software(Android Platform)
Application

Application
Android Runtime
Linux kernel

Hardware
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.4. Android from the technical aspect
•Android is composed of 5 elements
Components of Android
Application

⑤

Home

Address

Call

Application

Browser

Application framework

④

Activity

Window
manager

Content
provider

View
system

Package
management

Acknowledgement
management

Call
management

Resource
management

Position
management

Sensor
management

Library

②

Surface
manager

libc
Media
framework

SQLite

OpenGL I ES

FreeType

Webkit

Android run-time

SGL

SSL

①

③

Core
library

Dalvik VM

Linux kernel
Display
driver

Bluetooth
driver

Camera
driver

Flash memory
driver

Binder
( IRC)

Keypad
driver

USB
driver

Hardware
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.

WiFi
driver

Audio
driver

Electric power
management
1.4. Android from the technical aspect
• Components overview
①.Linux kernel
• Linux kernel is based on Linux 2.6 and added some Android features
• Include the hardware that provides the necessary functions to run
applications

②.Library
• Library is created by C/C++
– Webkit (Web browser Draw), SQLite (Database), OpenGL/SE (3D draw), …

• Library is used through application framework by application.

③.Android runtime
• The execution environment of Android applications
• Core Java Libraries includes Virtual machine execution environment (Dalvik
VM)

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.4. Android from the technical aspect
• Components overview
④. Application Framework
• Provides necessary Java API to use applications behavior/operation and
Libraries

⑤. Application
• Android applications are developed by using application framework
– Such as: Telephone, Web browser, Address book, etc…

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.4. Android from the technical aspect
• The lightweight runtime environment for Mobile
– Dalvik virtual machine (Dalvik VM)
• Optimization of Java VM for small-memory environment
– Google has developed its own virtual machine
– Be designed to allow simultaneity execution of multiple applications
even in low-memory environment

– Dalvik executables format (.dex)
• In Dalvik VM, the standard .class, .jar are converted into .dex to run
• Compare with .class, the memory size used when running is small
Java VM

.class

Dalvik VM
convert

.dex
.jar
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.4. Android from the technical aspect
– Dalvik VM is not compatible with Java VM
• The binary format of Executable files are different
– In Dalvik VM, file format .class, .jar can not run
– In Java VM, file format .dex can not run

Java VM

Dalvik VM

.class

.dex
.jar

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.4. Android from the technical aspect
• If there is no comparison about portable limit, Android applications is
almost the same with Java applications operating on PC.
i - Application (Doja-5.x)※1

Android Application

Java support

Java ME

Java SE

Application size limit

1MB (depend on model)

None

Heap memory limit

6MB~15MB (depend on models)

16MB (SDK setting value) ※2

Transmit limit

Unable to transmit except
application download origin

None

HTTP transmit size
limit

Request body: 80KB
Response body: 150KB

None

Cookies

Available with model released
from 2009 summer

Available

Character code

SJIS

UTF-8

Persistence method

ScratchPad

File, SQLite

※1. i - Application Content Development Guide for Doja-5.x/5.x LE~ Detail Part ~Version 3.00
※2. Default setting value in SDK, may be changed according to models. Fro example, Nexus One is 24MB.
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.5. Application development environment
Item

Necessary environment

OS

Windows XP, Windows Vista (32 / 64 bit)
From Mac OS X 10.5.8 onwards (x86 only)
Linux (already tested on Ubuntu Hardy Herson)

Java SDK

Java SDK 5, Java SDK 6

Android Development Tools

Android SDK

Integrated Development
Environment

Eclipse 3.4 (Ganymede), 3.5 (Galileo)
Android Development Tools (ADT) Plug-in

Text-based
Development environment

Apache Ant (From Windows version 1.7, Mac/Linux version 1.6.5
onwards)

 Actual equipment is not required. Emulator for development is available.
 Emulator may have some parts (such as sensor, etc.) unavailable.

Refer for details: http://developer.android.com/intl/ja/sdk/requirements.html
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.6. How to distribute Applications?
• There are 2 main ways to distribute Applications
– Distribute via Android Market
– Distribute without using Android Market
※ What is Android Market?
– Is a Website for distribution/sale Android Applications
– Is a common way to distribute Android Applications

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.6. How to distribute Applications?
• Distribute via Android Market site
– Distribution process
1.

Register Developer account on Android Market site
– To register Developer account, you must have Google account

2.

Create digital certificate for Applications※1
– Use Keytool (includes Java SDK) ※2 to create certificate

3.

Applications must be digitally signed※1
– Use jarsigner (includes Java SDK) ※2 to make digital signature

4.

Upload Applications onto Android Market
※1 Can create certificate, make sign by Eclipse functions
※2 Refer Tools manual to know the Tools usage

– Requirement
•

Google Account
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.6. How to distribute Applications?
• Distribute via Android Market site
– Process of register Developer account on Android Market
site
1.

Register developer profile on Developer registration site
– Registration Site
» http://market.android.com/publish/signup

– Input Profile items
»
»
»
»

2.
3.

Name
Mail address (need Google Account)
Web site URL
Phone number

Payment for registration ($25)
– Can payment with Credit card via Google checkout
Agree with Distribution Agreement
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.6. How to distribute Applications?
• Distribute without using Android Market site
– Distribute Application Files directly
• Example
– Distribute Files via Homepage
– Distribute Files by CD, USB memory, …
– Distribute Files over network such as LAN environments

• Distribution process
1. Create digital certificate for Applications
2. Digitally sign Applications
3. Distribute Application Files

• Installation method
1. Using Android terminals to download and install files
2. Connect USB with PC and Android terminal, use install command to
install
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.6. How to distribute Applications?
• Distribute without using Android Market site
– Installation Method ①
Using Android terminals to download and install Application files
• Process
1. Use browser of Android Terminal to download Application file
2. After the download is completed, click on the Application file on
download history
3. Press “Install” on Install confirmation screen

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
1.6. How to distribute Applications?
• Distribute without using Android Market site
– Installation Method ①

Click on file
Click on
Download file
Click on Install
button

Step 1

Step 2
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.

Step 3
1.6. How to distribute Applications?
• Distribute without using Android Market site
– Installation Method ②
Connect USB with PC and Android terminal, use Install
command to install
• Process
1.
2.

Use USB cable to connect PC and Android terminal
Start Command prompt, execute adb install command
>adb install < Application file name(.apk)>

■Install Input Command Prompt( C:Simeji3.0.6.apk )by USB
C:>adb install C:Simeji3.0.6.apk // ・・・ Step 1
596 KB/s (1413225 bytes in 2.312s)
pkg: /data/local/tmp/Simeji3.0.6.apk
Success // ・・・ Step 2
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2. Android Application
Architecture

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
Chapter 2: Overview
• Main components
• Life cycle
• The security of Android

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1. Main components
• The components of Android are available to achieve
key features of application
Key features of a common Application
User
interface

Inter-process
communication

Activity

Intent

External
communication

File Access

Perform
Background

Actualize

Content
Provider

Main components of Android
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.

Broadcast
Receiver

Service
2.1. Main components
• There are 5 basic components:
1.
2.
3.
4.
5.

Activity
Intent
Broadcast Receiver
Service
Content Provider

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.1. Activity
• What is Activity?
– The Android application screen is created by placing many
parts such as Button, Checkbox, … on Activity
– One screen is composed of one activity
– Activity has running and pausing status

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.1. Activity
• The Android application screen is created by placing
many parts such as Button, Checkbox, … on Activity

①
②

The left figure is activity which view (button)
placed on
1. Activity
2. View (button)
The left figure screen is shown in the following
configuration

2. View ( button)
1. Activity
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.1. Activity
• Can handle to respond to user input screen
– On screen, the information of operation (Ex: click on
button) will be notified to Activity via View
– Activity can handle to respond to the notification
• Ex: after click on the button

3.Execute the handler when
button clicked

1. Click on button

Button

2.Notify

Activity

public void onClick(View view)
{
// View message on screen
}

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.1. Activity
• One screen is composed of one activity
– For Application has multiple screens, the number of
activities is equal to the number of screens.
Application

Application
Activity

Activity

Activity
Activity

The Application is composed
by 1 screen

The Application is composed
by 3 screens

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.1. Activity
• Activity displayed mechanism
– On screen, at one time, only one activity is displayed
• In Android Application, even if there are many activities, only 1
activity can be displayed
• For display new Activity, previous activity is hidden, new activity is
displayed on above

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.1. Activity
• There are several states of activity, the state is changed by
operation
• State of activity has defined in 3 types:
1. Foreground status
• When activity is being displayed, the cursor is in working condition

2. Background status
• Activity is in hidden condition by another activity

3. Visible status
• When no activity screen is displayed (dialog…), the activity cursor is in losing condition (activity is
being displayed over dialog)

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.1. Activity
• The kind of activity is used depend on the type of screen
– Example of Activity
#

Screen

Using Activity class

1

Single Screen

Activity class

2

List display Screen

ListActivity class

3

Map Screen (Google Map)

MapActivity class

1. Single Screen (use Activity)

2. List display Screen
(use ListActivity)

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.

3. Map Screen (use MapActivity)
2.1.2. View
• What is View?
– Buttons, checkboxes, spinners, …
– The View that contains other views is called ViewGroup
• The relation of Activity, View and ViewGroup

User Interface
View

View

ViewGroup
View

ViewGroup
Activity
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.

View
2.1.2. View
• Typical View
View name

Overview

TextView

Display text

Button

Basic press button

EditText

Input text

CheckBox

The button has ON/OFF status

Spinner

This button for choose one item from the list

AnalogClock

Analog Clock

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.

Image
2.1.2. View
• Typical ViewGroup
Name

Overview

LinearLayout

• The ViewGroup that view is placed in horizontal or vertical
direction
• Display scroll bar in case it’s not fit in screen

TableLayout

• The ViewGroup that view is placed in grid (similar HTML table
tags)
• TableRow is specified inside

TableRow

• The ViewGroup that view is placed in Table line

ListView

• The ViewGroup that view is placed in one list
• Display scroll bar in case it’s not fit in screen

TabHost

• The ViewGroup that display is replaced by switching tabs

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.2. View
• Can create the original view (Custom Views)
– Custom Views can be created in 3 ways
• Extending an existing View
– Effective way if you want to add functionally into an existing View

• Inherit from basic class (android.view.View)
– If you want to create a completely new View
– Possible for develop a View in most freedom
– Require deep knowledge of basic class for implementation from scratch

• Combine existing Views, ViewGroups to create a new View
■ For more detail, please refer Android Developers in Development Guide
http://developer.android.com/intl/ja/guide/topics/ui/custom-components.html

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.3. Intent
• What is intent?
– The mechanism to request a process and to exchange
message between components
• The components can use intent are activity, broadcast receiver and
service

– Example:
• Start activity B from activity A (screen transition)
• Send request “call phone” from Address book application to Make call
application

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.3. Intent
• Call out component by intent: the intent containing
the information of caller component give call out
request for Android
– The sample of calling out B component from A component

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.3. Intent
• There are 2 ways in using intent: using explicit intents
and using implicit intents
– Using Explicit intents
• This way is used in case of called component is designated its name directly.
It is used to call out components in the same application (such as screen
transition)
– The sample of calling out designated component

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.3. Intent
– Using Implicit intents
• This way is used in case of the called component is not designated (named),
only specify action (Sample in under figure: specify to “make a telephone
call”). Often used to call out components in other Applications (such as other
Application screen)
• From configuration information of components, Android will determine
which component be started.
– The sample of calling out an specified action

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.3. Intent
– Using Implicit intents (continuous)
• When using Implicit intents, by cooperating with Android’s
applications, the following tasks can be done
– Phone Application
» Open Dial window of specified number
– Address book Application
» Display address book list
» Display information of 1 address in address book
» Edit information of specified address
– Web browser
» Use Browser to display the URL address of specified Website

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.3. Intent
– Using Implicit intents (continuous)
• Implicit intents can send broadcast for whole system
• Intents sent by sending broadcast (broadcasted intent) is used to
report the change with condition, such as “Complete system
startup”, “Change battery occurred”, …
• Intents sent by sending broadcast (broadcasted intents) are intents
that can receive only Broadcast receivers.

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.4. Broadcast receiver
• What is Broadcast receiver?
– Broadcast receiver is a mechanism for responding with
intents sent by sending broadcast
– Can create peculiar Broadcast receiver by inheriting
BroadcastReceiver class

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.4. Broadcast receiver
• Example of using Broadcast receiver
– Check mail when starting up Android terminal
1.
2.

Receive broadcast intent when Android terminal startup complete
by Broadcast receiver
Broadcast receiver call out Mail check service
※ Although mail check process can be executed from Broadcast receiver directly,
but it’s more efficient when using Service to deal with time-consuming

① Complete startup
message
Intent

② Execute Mail check
service
Broadcast
receiver

Intent

Send broadcast intent
Receive intent
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.

Mail check
service
2.1.4. Broadcast receiver
• Can use Broadcast receiver to create a process started
by system notification
– Define the action of broadcast intent (some excerpts)
#

Constant name of Intent class

Condition

Setting value

1

ACTION_BOOT_COMPLETED

Completed system
startup

android.intent.action. BOOT_COMPLETED

2

ACTION_TIME_CHANGED

Time set up

android.intent.action.TIME_SET

3

ACTION_TIMEZONE_CHANGED

The time zone is
changed

android.intent.action.TIMEZONE_CHANGED

4

ACTION_PACKAGE_ADDED

The Application is new
installed

android.intent.action. PACKAGE_ADDED

5

ACTION_PACKAGE_REMOVED

The Application is
uninstalled

android.intent.action. PACKAGE_REMOVED

6

ACTION_BATTERY_CHANGED

Whether charging, the
battery is changed

android.intent.action. BATTERY_CHANGED

■ Please refer more setting value at the following URL
http://developer.android.com/intl/ja/reference/android/content/Intent.html
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.5. Service
• What is service?
– The mechanism to execute a process by independent thread
– Service and foreground’s activity are executed in separate threads.
Therefore, the process can continuous even if an interrupt occurred
with other activities.
Play music (not use Service)

Play music (use Service)

The difference in operating when Activity interrupt
occurred by receiving mail in case of playing music
directly from Activity or through service.

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.5. Service
• Introduction about application which used service
– DroidTracker: The application for sending location information get by
GPS through SMS, mail, twitter.

 Processing location information acquisition
by GPS function through Service.
 Processing SMS, mail, twitter sending
functions through Service.

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.6. Content provider
• What is Content provider?
– The mechanism that allows the application that holding data
can be accessed (search, insert, update, delete) from other
applications
– Example
• Access phone call log from application
• Insert Website into browser bookmarks from application
※ Data means the information that is persisted in files, database of application

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.6. Content provider
• Why content provider must be used to access to other
applications’ data?
– The data kept in application can not be access directly from
external applications
Security wall

Application

Get information
External
Applications

Storage
Edit information
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.6. Content provider
• Content provider has mechanism to realize/achieve
the access from external applications

Security wall

Application
Content
provider

Get information
External
Applications

Storage
Edit information
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.1.6. Content provider
• In order to achieve a secure access, content provider
will settle the interfaces
– Main interfaces
# Event name

Content

1 Query

Search data, then
return searching
results

2 Insert

Insert data

3 Update

Update data

4 Delete

Content provider

Delete data

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.

Interface is
settled

query
insert
update
delete

External
Applications
2.1.6. Content provider
• In Android, depend on content provider, data has been
published
– Published data
•
•
•
•
•
•
•

Phone call log
Contact list
Browser Bookmarks
Browser Search history
Images in Media
Pictures in Media
Audio in Media

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.2. Life cycle
• What is Life cycle?
– In Activity and Service, Life cycle is defined as the life cycle of
object from creation until destruction.

Activity Life cycle

Service Life cycle

This material is licensed under the Creative Commons License BY-NC-SA 4.0.
2.2.1. Activity Life cycle
• Activity Lifecycle
– 3 types of status transition are determined in an activity
(Foreground, background, visible)
– When status change occurs, Event will be notified.

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.2.1. Activity Life cycle
• Life cycle includes notified events

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.2.1. Activity Life cycle
• In an Activity, the following events are notified. The
developers can create a process to respond to these
notifications
– Notified events
# Events name

Content

1 onCreate

The event occurs in the initial startup

2 onStart

The event occurs just before the activity is displayed

3 onResume

The event occurs just before the activity is available (active status)

4 onPause

The event occurs just before the activity becomes visible

5 onStop

The event occurs in case of unused status for a while after onPause
(The event may not occur when lack of memory)

6 onRestart

The event occurs when stopped activity is showed again

7 onDestroy

The event occurs just before the activity is annulled
(The event may not occur when lack of memory)
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.2.1. Activity Life cycle
• Notes about Activity notification event
– Not ensure that onStop, onDestroy are always be notified
• In case memory run out, Android
will stop unused application processes
forcedly
• In this case, onStop, onDestroy
notifications in Activity Life cycle
can not be ensured
• In case it’s a absolute necessary
process, use onPause to processing
The transition route in case of
memory run out
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.2.2. Service Life cycle
• The Service Life cycle is defined
as the right figure
• For an event is notified when
changing state like in Activity,
the process to respond to
notifications can be created
# Events name

Content

1 onCreate

The event occurs in the first startup

2 onStart

The event occurs just before the Service is
started

3 onDestroy

The event occurs just before the Service is
destroyed
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.3. Android Security
• To use the functions of Hardware such as network,
camera, … the permission to use information of each
application must be set
– The operations that can affect on OS, application, user data,
… are restricted in Application

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.3. Android Security
• The method of setting application use permission
1. Insert uses-permission tags in AndroidManifest.xml
2. Set the set value of Permission Function in android:name
※ In below sample: Permit an application to connect to the Internet
■ Setting sample
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android=http://schemas.android.com/apk/res/android
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name">
・・・
Setting the permission information
</application>
for Internet Connection
<uses-sdk android:minSdkVersion="3" />
<uses-permission android:name=“android.permission.INTERNET“/> // ・・・ Step1,2
</manifest>
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.3. Android Security
• In other to use the following functions, Android
application set up the permission information into
AndroidManifest.xml
– The sample of Permission information set value
Set value (android.permission)

Explanation

INTERNET

Internet connection

ACCESS_FINE_LOCATION

Location information(GPS…)accession

CALL_PHONE

Call without using call out screen

READ_CONTACTS

Read in Address book

WRITE_CONTACTS

Write into Address book

CAMERA

Camera devices accession

Please refer the other set value at following URL
http://developer.android.com/intl/ja/reference/android/Manifest.permission.html
This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
2.3. Android Security
• When install an application that includes use
permission information, the confirmation for
permitted information is executed

Confirmation of Internet
Connection permission

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
3. Development Environment
Preparation

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
Chapter 3: Overview
• Development Tools Installation
• Development Tools Installation method
– Development Tool use the things stored in
C:android_trainingdevtools

• Emulator preparation
– Android Virtual Device (AVD) creation
– AVD verify operation

This material is licensed under the Creative Commons License BY-NC-SA 4.0.
3.1. Development Tools Installation
• In this training, the following Development Tools will
be installed
Software

Version

Integration Development
environment

Eclipse 3.5 (Galileo)

Java SDK

JDK 1.6.0_20

Android SDK

2.1 r2

Android Plug-in

Android Development Tools (ADT) Ver.0.9.X

This material is licensed under the Creative Commons License BY-NC-SA 4.0.
3.2. Development Tools Installation method
• Android SDK Installation
1. Start explorer from Start Menu/[ All Program]-[Accessories]/[Explorer], open
C:android_trainingdevtools
2. Right click on File android-sdk_r06-windows.zip, then choose [Open from
program]-[Compresses (zip) Folders]
3. Move folder android-sdk-windows within zip into C:android_training tools

3
2

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

82
3.2. Development Tools Installation method
• Setting Environment variables
1.
2.

Open Control panel from Start Menu/ [ Control Panel], double click on
[System]
System/ Properties Window, on [Detail setting] Tag, click on [variable
Environment] Button

1

2

This material is licensed under the Creative Commons License BY-NC-SA 4.0.
3.2. Development Tools Installation method
3.
4.

5.
6.

From a Environment variable window/[System Environment
variables], select [Path], then click on [Edit] button
Insert C:android_trainingtoolsandroid-sdk-windowstools; into the
head of variable value in Edit window of System variable
Click on [OK] button in Edit window of System variable
Click on [OK] button in Environment variable window
Insert

4

3

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

84
3.2. Development Tools Installation method
7.

Check the reflect of change in environment variable
1. Click on [Command prompt] in Start Menu/[ All program]-[ Accessories] to
start Command prompt
2. Execute command set<sp>|<sp>find<sp> “android” from Command
prompt, check to make sure that Path setting is displayed (Refer below chart
for output result)
※ <sp> ・・・ means Space

This material is licensed under the Creative Commons License BY-NC-SA 4.0.
3.2. Development Tools Installation method
• Android Development Tools (ADT) Installation
1.
2.

Start Eclipse
On the Menu [Help] of Eclipse, select [Install New Software…]

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

86
3.2. Development Tools Installation method
3.

If Network environment is using Proxy, make the following settings
i.
ii.
iii.

On the Menu [Window] of Eclipse, select [Preferences]
On Preferences window, select [General]-[Network Connections]
From Network Connections screen, select 「Manual Proxy Configuration」,
setting the items below:
–
–

HTTP Proxy: Proxy Server address (For example: 192.168.1.1)
Port
:Port number of Proxy Server (For example with right chart 80)

ii

ii
i

i

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

87
3.2. Development Tools Installation method
4.

Input http://dl-ssl.google.com/android/eclipse/ into “Work with” of
Available Software window, then press Enter.

4
http://dl-ssl.google.com/android/eclipse/

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

88
3.2. Development Tools Installation method
• Alternative method in case failed to connect to server
4-1. Click on button [Add...] of Available Software window.
4-2. Click on button [Archive] at Add Site window.
4-3. Input ADT-0.9.X.zip into “File name” as file in folder
C:android_trainingdevtoolsforOffline, click on [Open] button,
then click on [OK] button.
4-1

4-2

C:android_trainingdevtoolsforOffline
4-3

This material is licensed under the Creative Commons License BY-NC-SA 4.0.

89
3.2. Development Tools Installation method
5.
6.

Check Android DDMS, Android Development Tools in Available
Software window, click on [Next] button.
Click on [Next] button in Install window.

5
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

6
90
3.2. Development Tools Installation method
7.
8.

On Install window, check [I accept the terms of the license
agreements], then click on [Finish] button. Installation begins
Installation complete, click on [Yes] when Software Updates message
displayed, restart Eclipse

9

8
This material is licensed under the Creative Commons License BY-NC-SA 4.0.
3.2. Development Tools Installation method
9.

After restarting Eclipse, check to make sure that Android
Development Tools button has been inserted into Toolbar.
1
0

The Tool button of Android
Development Tools is
displayed

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

92
3.2. Development Tools Installation method
• Set up Eclipse
– Recognize Android SDK in ADT
1. From Menu [Window] of Eclipse, select [Preferences]

1

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

93
3.2. Development Tools Installation method
2.
3.

4.

From Preferences window, select [Android]. After selected, Error
Message will be displayed, click [OK] to close Message window.
In SDK Location, input 「 C:android_trainingtoolsandroid-sdkwindows」
Check to make sure that Error message on the top of Preferences
window is disappeared, then click [OK] button.
3

2

Check that Error
message is
disappeared
C:android_trainingtoolsandroid-sdkwindows

4
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

94
3.2. Development Tools Installation method
5.

If Network environment is using Proxy, make the following settings:
i.
ii.

From Preferences window, select [Android]-[Launch]
From the Launch screen, insert Proxy setup into [Default Emulator Options]
(Format: -http-proxy<sp><Proxy Server address>:<Port number> )
–

If Proxy Server address is「 http://192.168.1.1 」, Port number is「80」, make
setup as follow
»
-http-proxy http://192.168.1.1:80

i

ii

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

95
3.2. Development Tools Installation method
6.

Select [Android SDK and AVD Manager] from menu [Window] of
Eclipse.

6

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

96
3.2. Development Tools Installation method
7.
8.

Select Available Packages from left column of Android SDK and AVD
Manager window.
Click on [+] of URL on right column to drop down, check on [SDK
Platform Android 2.1, API-7, revision 2] then click on [Install Selected]
button.

※ In offline environment, copy platform folder of C:android_trainingdevtoolsforOffline to
C:android_trainingtoolsandroid-sdk-windows in responding to instruction of Trainer.

7

8

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

97
3.2. Development Tools Installation method
9.

Select [Accept] in “Choose Packages to Install” window , then click on
[Install] button.
10. After installation finished, click [Close] button to finish installation.

1
0

9

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

98
3.3. Emulator preparation
• Create Android Virtual Device (AVD) that is device
image of Emulator
1.

From menu [Window] of Eclipse, select [Android SDK and AVD
Manager].

1

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

99
3.3. Emulator preparation
2.

Click on [New] button of Android SDK Devices window.

2

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

100
3.3. Emulator preparation
3.

When “Create new Android Virtual Device” window is displayed, set
up parameters as below.
Item name Set up value
Name

Android 2.1-update1

Skin

4.

default

Target

3

WVGA800

After finished setting, click on
[Create AVD] button.

4
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

101
3.3. Emulator preparation
• Start the Emulator, check that AVD has been created
1.
2.

Start up “Android SDK and AVD Manager” in Eclipse, select Default for AVD
Name, click on [Start] button.
Check on [Scale display to real size] in “Launch Option” window, input “6” into
[Screen Size (in)], then click on [Launch] button.

1
Input appropriate size
according to environment.

2

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

102
3.3. Emulator preparation
3.

Check to make sure that Emulator screen as below will be displayed.

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

103
4. Tutorials

This material is licensed under the Creative
Commons License BY-NC-SA 4.0.
Chapter 4: Overview
• Learn how to operate Development Tools through
creation of HelloWorld application
– Android Development Tools (ADT)
– Emulator, Android Virtual Device (AVD)
– Dalvik Debug Monitor Services (DDMS)

This material is licensed under the Creative Commons License BY-NC-SA 4.0.
4.1. Create an application by ADT
• What is Android Development Tools (ADT)?
– Plug-in to develop Android applications by Eclipse.

• The functions that ADT provides
– Create Android projects
– Execute/ debug Android applications
– Support to Resource files creation
• Resource files will be described in this section

This material is licensed under the Creative Commons License BY-NC-SA 4.0.
p
r
a
c
t
i
c
e

4.1.1. Display Hello World
• The beginning of an Android project, create the below
application
– Complete image
New project is creation an application
that displays Hello World HelloWorld!
like in the left chart

This material is licensed under the Creative Commons License BY-NC-SA 4.0.
p
r
a
c
t
i
c
e

4.1.1. Display Hello World
•

Create Android project
1.
2.
3.

Double click eclipse on desktop to start up Eclipse.
Select [new]-[Other ] from menu [File] of Eclipse.
Select [Android]-[Android Project] of New window , then click on
[Next] button.

3

2

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

108
p
r
a
c
t
i
c
e

4.1.1. Display Hello World
4.

Input following information into Project Name, Build Target,
Properties from window [New Android Project].

Input HelloWorld into Project Name

Check Android 2.1-update1 on Build Target
Input following information into the following
items of Properties
Application Name :HelloWorld
Package Name
:jp.oesf.tutorial
Create Activity
:HelloWorld
MinSDK Version
:7
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

109
p
r
a
c
t
i
c
e

4.1.1. Display Hello World
5.
6.

Android Project will be created, and be displayed as in left-hand
picture.
Select HelloWorld project from Package Explorer, right click then
select [Run As]-[Android Application].

4

5

5

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

110
p
r
a
c
t
i
c
e

4.1.1. Display Hello World
7.

Start Emulator on other window, confirm to be sure that the following
screen is displayed.
•
•

Application title is HelloWorld.
“Hello World, HelloWorld!” is displayed in application.

6

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

111
4.2. Create screen design
• Create screen design on Resource file
– What is resource file?
• All external files besides source code.
• Files stored below /res in Android Project.

– Types of resource file (partial excluded)
#

Resource file

Content

1 res/drawable(-Xdpi)/*.*

Image file (.png, .jpeg, .gif)

2 res/layout/*.xml

Screen design information (ex. main.xml)

3 res/values/colors.xml

Color information

4 res/values/dimens.xml

Size information (ex. 5px, 10dip, 20pt)

5 res/values/strings.xml

Character string information

■Explanations related to resource file
http://developer.android.com/intl/ja/guide/topics/resources/resources-i18n.html
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

112
4.2. Create screen design
• There is function supports creating resource file in
ADT.
– ADT supply 3 kinds of resource file editor
• Layout editor
– Support creating screen design resource file.

• Resource editor
– Support creating resource file besides screen design resource file.

• Manifest editor
– Support creating AndroidManifest.xml

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

113
p
r
a
c
t
i
c
e

4.2. Create screen design
• Use function Layout Editor, create screen that include
button, check box, text input in HelloWorld.
– Completed image
• Use GUI function of Layout editor to add button
and check box.
• Edit directly screen design resource file (XML file)
to add text input.
• Setting as below for display character string of
every View.
# View

Display string character

1 Button

Button01

2 Check Box

CB1

3 Text input

EditText

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

114
p
r
a
c
t
i
c
e

4.2.1. Create resource file
•

Open screen design resource file
1.
2.

Double click res/layout/main.xml from Package Explorer.
When res/layout/main.xml file is opened by Layout Editor, confirm to
be sure that the screen on the right-hand picture is displayed.
2

1

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

115
p
r
a
c
t
i
c
e

4.2.1. Create resource file
•

Insert button, check box into screen design by
Layout tab of Layout Editor.
1.
2.
3.

Select Button from [Views], drag & drop on the screen.
The button will be displayed as the right-hand picture.
Similarly, drag & drop CheckBox from [Views] on the screen and then
confirm to be sure that it is displayed.

2
1
Drag & drop

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

116
p
r
a
c
t
i
c
e

4.2.1. Create resource file
4.

5.

Select CheckBox01 on the screen, change Text properties from
CheckBox01 to CB1 from Properties Views.
Similarly, change Text properties of @+id/Button01 into Button01.
Select HelloWorld project from Package Explorer, right click then
select [Run As]-[Android Application].

5

5
5

4

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

117
p
r
a
c
t
i
c
e

4.2.1. Create resource file
6.

Start emulator, confirm to be sure that below screen is displayed .
• CheckBox, Button is displayed on screen.
• Confirm to make sure display character string of Button is Button01.
• Confirm to make sure display character string of CheckBox is CB1.

6

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

118
p
r
a
c
t
i
c
e

4.2.1. Create resource file
• Add text input into screen design by tab <File name>
of Layout editor
1.

Click on tab main.xml of Layout editor, confirm to be sure that XML
source is displayed in Layout editor.
■res/layout/main.xml(partial omitted)

1

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=http://schemas.android.com/apk/res/android
・・・・・・・・・・・
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>
<Button
android:text="Button01"
android:id="@+id/Button01“
・・・・・・・・・></Button>
<CheckBox
android:id="@+id/CheckBox01“
android:text="CB1“
・・・・・・・・・ ></CheckBox>
</LinearLayout>

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

119
p
r
a
c
t
i
c
e

4.2.1. Create resource file
2.

Add EditText tag that is Text Input View into main.xml.
■res/layout/main.xml(partial omitted)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android=http://schemas.android.com/apk/res/android
・・・・・・・・・・・
>
<TextView
・・・・・・・・・・・
/>
<Button
・・・・・・・・・></Button>
<CheckBox
・・・・・・・・・ ></CheckBox>
<EditText
android:id="@+id/EditText01"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="EditText"></EditText>
</LinearLayout>

2

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

120
p
r
a
c
t
i
c
e

4.2.1. Create resource file
3.

Switch display in Layout Tab, confirm to be sure that EditText is
displayed as below.

Switch display

EditText is displayed in
Layout Tab

3
EditText added

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

121
p
r
a
c
t
i
c
e

4.2.1. Create resource file
4.

Select HelloWorld project from Package Explorer, right click then
select [Run As]-[Android Application].
When Emulator starts, confirm to be sure that the right-hand screen is
displayed.

5.
•
•

4

Text input is displayed.
Display character string of Text input is EditText.

5

5

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

122
4.2.1. Create resource file
•

Attention points when using Layout Editor
1.

Although we tried to paste View group in Layout tab (View included in
Layout) to the screen by drop & drag, ViewGroup was not be
displayed on the screen.
•

2.

Handle the following matter by edit directly XML.
– Arrange View of buttons, etc. within ViewGroup.

Unable to select CustomView from [Views]
•

Handle by edit directly XML.

1

Although we arranged
LinearLayout but it is not
disaplayed

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

123
4.2.1. Create resource file
• Mechanism of screen create usage resource file
– Activity uses Class R to acquire content of screen design resource file.

• Class R
– Class generated automatically at the time of “build”.
– The class necessary to acquire information of resource file from program.
– Display screen design from resource file information acquired by Activity#setContentView.

■HelloWorld.java

R.layout.main will display main.xml
public class HelloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}

■setContentView
Display screen design on Activity

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
・・・・・・・・・・・
>
・・・・・・・・・・・
<EditText
android:id="@+id//EditText01“
・・・・・・・・・・・
android:text="EditText"></EditText>
</LinearLayout>

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

124
4.2.1. Create resource file
• Relationship between R class and resource file
– Program and resource information will be connected by resource ID.
■HelloWorld.java
setContentView(R.layout.main);
Reference

■R.java
public static final class layout {
public static final int main=0x7f030000;
}
Resource ID

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

Resource
file

125
p
r
a
c
t
i
c
e

4.3. Use resource besides design
• Change display character string “Button01” of button
that was added into HelloWorld to “Hello Button”.
• Set display character string into character string
resource file.
– Completed image

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

126
4.3. Use resource besides design
• Character string resource file is resource file defined character string using in
application. (res/values/strings.xml)
■Character string resource file (res/values/strings.xml)
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello World, HelloWorld!</string>
<string name="app_name">HelloWorld</string>
</resources>

Refer to
character
string

■TextView

1. Add character string
that displays on the
screen into character
string resource file.

on screen design resource file (res/layout/main.xml)

<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello"
/>

Execute

3. Character string set in
strings.xml is
displayed.

2. Refer to character string of character string resource
file from Text Properties in TextView

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

127
p
r
a
c
t
i
c
e

4.3. Use resource besides design
•

Insert character string set-up into character string
resource file.
1.
2.

Double click on res/values/strings.xml from Package Explorer.
Open file res/values/strings.xml by Resource Editor, then confirm to be sure that the right-hand
screen is displayed.

2

1

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

128
p
r
a
c
t
i
c
e

4.3. Use resource besides design
3.
4.

Click on [Add…] button of Resource Tab, display Option screen of
additional element.
Select String from Option screen, click [OK] button.

3
4

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

129
p
r
a
c
t
i
c
e

4.3. Use resource besides design
5.
6.

Confirm to be sure that String was inserted into Resources Elements
of Resources Tab.
Input value into Name, Value of “Attributes for String” of Resources
Tab as below.
Setting value of “Attributes for String”
Item Name

5

Name

button_label

Value

6

Setting value

Hello Button

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

130
p
r
a
c
t
i
c
e

4.3. Use resource besides design
7.
8.
9.

Double click on res/layout/main.xml from Package Explorer
After starting up Layout editor, open Layout Tab, then select Button01
Change Text properties into @string/button_label from Properties
View.

8

7

9

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

131
p
r
a
c
t
i
c
e

4.3. Use resource besides design
10. Select HelloWorld project from Package Explorer, right click then
select [Run As]-[Android Application].
11. Start emulator, confirm to be sure that the right-hand screen is
displayed.
•

Display character string of Button will become Hello Button.

11

10

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

132
4.4. Modify Manifest file
• Manifest editor
– There are 5 functions to modify Manifest file.
• Manifest Tab
– Version information, extension information, etc…

• Application Tab
– usage component information, icon, application name, etc…

• Permissions Tab
– Access limit setting

• Instrumentation Tab
– Setting Class used for information gathering of profile, etc… (ex: TestRunner,
etc…)

• AndroidManifest.xml Tab
– Edit directly XML file

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

133
4.4. Modify Manifest file
• What is manifest file?
– AndroidManifest.xml (1 file exists in application)
– Define the following information related to application.
•
•
•
•
•

Setting icon, title of application.
Definition about usage component (Activity, Service, etc…)
Definition related to conduct of component.
Setting access limit of application.
Setting usage of library.

■Explanation related to Manifest file.
http://developer.android.com/intl/ja/guide/topics/manifest/manifest-intro.html

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

134
4.4.1. Add Activities into application
• Add Activities into application
File name
Additional Activities

HelloWorld2.java

Additional screen
design resource file

res/layout/
helloworld2.xml

– Add Activities HelloWorld2 into application.
– The screen design resource file of
HelloWorld2 is helloworld2.xml.

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

135
4.4.1. Add Activities into application
•

Setting by Application Tab so that it is possible to use
Activities added to application.
1.
2.

Double click on AndroidManifest.xml from Package Explorer
Open file AndroidManifest.xml by Manifest editor. Select Application Tab in
Manifest editor, then confirm to be sure that the right-hand screen is
displayed.
2

1
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

136
4.4.1. Add Activities into application
3.
4.

Click on [Add…] button in Application Nodes, display Option screen of
additional element.
Select Activity from Option screen, then click [OK] button.

4

3

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

137
4.4.1. Add Activities into application
5.
6.

Confirm to be sure that Activity has been added into Application Nodes.
Input value as below into Name of Attributes for Activity.
Item name

Name

5

Setting value

HelloWorld2

6

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

138
4.4.2. Set up Right of access to internet
•

Set up Right of access to internet by Permissions Tab
1.
2.

Double click on AndroidManifest.xml from Package Explorer.
Open AndroidManifest.xml file by Manifest editor. Select Permissons Tab in
Manifest editor, confirm to be sure that the screen on the right-hand picture
is displayed.

2

1
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

139
4.4.2. Set up Right of access to internet
3.
4.

Click on [Add…] button in Permissions, display Option screen of additional
elements.
Select Uses Permisson from Option screen, then click on [OK] button.

3

4

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

140
4.4.2. Set up Right of access to internet
5.
6.

5

Confirm to be sure that Permission is added into Permissions.
Select android.permission.INTERNET from pull-down menu of Name in
Attributes for Uses Permission.

6

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

141
4.5. Usage method of emulator
• What is emulator?
– Read Android Virtual Device (AVD), emulate hardware operation on
computer.

• Function / Setting that not be supported by emulator
–
–
–
–
–
–
–

Actual incoming call, outgoing call
USB connection
Camera/Videographer
Headphone connection
Communication usage Bluetooth
Connection status setting
Battery charging level, AC power source setting

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

142
4.5. Usage method of emulator
• What is Android Virtual Device (AVD)?
– It contains Android terminal information.
• Android operating environment information
(Operating environment for every version of Android)
• Skin information (outside exterior, monitor size)
• SD Card information

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

143
4.5. Usage method of emulator
• Operating method of emulator
#

Device key

Content

1 Volume UP
1 2 3

2

Volume DOWN

11

4

3 Power source

Power On/Off

10

5

4 Select button

Select button

5 End call
9 8 7 6

Home
Move to Search window

7 Return

Return to previous screen

8 Menu
12

6 Search

Display menu on the screen

9 Home

Display home

10 Start call
8

11 Cross key

Move cursor

12 Keyboard

Key input

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

144
4.5. Usage method of emulator
• Switching screen orientation (Ctrl + F11)
– Screen display that fits orientation of device.

Portrait display

Landscape display

Detail information related to Android emulator
http://developer.android.com/intl/ja/guide/developing/tools/emulator.html
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

145
4.6. Usage method of debug tool
• ADT
– We can use debug function of Eclipse in Android application
development.
• Breakpoint
• Step execution

• Dalvik Debug Monitor Services (DDMS)
– Android SDK Debug tool pack
– There are functions as below:
• Monitoring
• Emulator operating
• Acquiring information in emulator/hardware

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

146
4.6.1. Usage method of ADT
• Usage method of Breakpoint/Step execution
– Both of setting method of Breakpoint/Step execution are similar to
usage method of Eclipse.
Debug View and
Step execution

Interrupt
processing by
Breakpoint

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

147
4.6.1. Usage method of ADT
• Attention points when debugging on ADT
– It is necessary to set up in AndroidManifest.xml to debug using
hardware (Real Android terminal).
■AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="jp.oesf.mtgeduwg.training.rssreader"
android:versionCode="1"
android:versionName="1.0">
<application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true">
・・・
</application>
Set up debug
<uses-sdk android:minSdkVersion=“7" />
</manifest>
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

148
4.6.2. Usage method of DDMS
• 2 methods to start DDMS
–

Execute ddms command
1.

2.

Select [Command prompt] in [All programs]-[Accessories] on Start Menu,
then start Command prompt.
Input ddms in Command prompt, then press [Enter] key.

DDMS started from command

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

149
4.6.2. Usage method of DDMS
• 2 methods to start DDMS
–

Use DDMS from Eclipse
1.

Select [Open Perspective]-[Other…]-[DDMS] from menu [Window] of
Eclipse.

※There is some functions that are unavailable compared to DDMS that
started command.

DDMS perspective of Eclipse

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

150
4.6.2. Usage method of DDMS
•

Debug function of DDMS
–

Monitoring
1.
2.

–

Transmitting data to emulator
1.
2.
3.

–
–

Outgoing call
SMS sending
Transmit position information

Acquiring screenshot
Process management
1.
2.

–

Refer to log that application output
Refer to usage status resource

Execute garbage collection
Interrupt process

File operation
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

151
4.6.3. Application log reference
• Application log reference
– We can refer to log that application outputs from LogCat view.

LogCat
Display log information that
be output from application.

Log Level
Level

E

Error information

W

Warning information

I

Operation information

D

Debug information

V

Detail information

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

152
4.6.3. Application log reference
• Application log reference
– Use log output method of android.util.Log class to output log.

■ Sample code
import android.util.Log;
Log.e(“HelloWorld”, “Error Message”);
// Log that outputs errors
Log.w(“HelloWorld”, “Warning Message”);
// Log that outputs warnings
Log.i(“HelloWorld”, “Infomation Message”); // Log that outputs information of application operation
Log.d(“HelloWorld”, “Debug Message”);
// Log that outputs debug information
Log.v(“HelloWorld”, “Verbose Message”);
// Log that outputs detail information

Output Log

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

153
p
r
a
c
t
i
c
e

4.6.4. Output log from Hello World
• Output application log when starting HelloWorld
1.
2.

Double click on HelloWorld.java from Package Explorer.
Confirm to make sure that source code of HelloWorld.java is opened,
screen on the right-hand picture is displayed.
2
1

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

154
p
r
a
c
t
i
c
e

4.6.4. Output log from Hello World
3.

Add 5 code that execute log output into HelloWorld#onCreate.
■HelloWorld.java
package jp.oesf.tutorial;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
public class HelloWorld extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Log.e("HelloWorld", "Error Message");
Log.w("HelloWorld", "Warning Message");
Log.i("HelloWorld", "Infomation Message");
Log.d("HelloWorld", "Debug Message");
Log.v("HelloWorld", "Verbose Message");

6

}

}
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

155
p
r
a
c
t
i
c
e

4.6.4. Output log from Hello World
4.
5.

Select HelloWorld project from Package Explorer, right click then select
[Run As]-[Android Application].
Confirm to be sure that emulator runs & right-hand screen is displayed.
5

4

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

156
p
r
a
c
t
i
c
e

4.6.4. Output log from Hello World
6.
7.

Modify perspective of Eclipse into DDMS, confirm to be sure that
screen of DDMS is displayed.
Confirm to be sure that 5 logs are output in LogCat view.
6

7

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

157
4.6.5. Confirm resource usage status
• Refer to resource usage status
– Information available to refer and display screen
• Info view (Only when executing command)
– Display process information (ID, DalvikVM information)

• Threads View
– Display information of operating threads.

• VM Heap View
– Display usage status of Heap memory.

• Allocation Tracker View
– Display memory ensure status (ensure class, method, etc…).

• Sysinfo View (only when executing command)
– Display in graph format system status (CPU usage rate, memory status).

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

158
4.6.5. Confirm resource usage status
• Refer to VM Heap information

Set Update into process that you
want to display Heap information.

Display in list the following
items:
Type of objects
Number of objects
Total amount of usage
memory
Minimum usage memory
Maximum usage memory
Average usage memory

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

159
p
r
a
c
t
i
c
e

4.6.6. Transmit call to emulator
•

Transmit call (Transmit call to emulator)
1.
2.
3.

Select Emulator Control View.
Input phone number (09010000001) into Incoming number.
Select Voice, then click [Call] button.
Emulator Control

Input incoming number
ex.
Incoming number : 09010000001
Select Voice

Call
: Transmit call
Hang Up : Hang up the phone

1

Transmit call to Emulator, send
SMS, position information.

2

3

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

160
p
r
a
c
t
i
c
e

4.6.6. Transmit call to emulator
4. Confirm incoming call from 09010000001 to emulator.
4
Incoming call to emulator
from 09010000001

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

161
4.6.7. Send SMS to emulator
•

SMS sending (Send SMS to emulator)
1.
2.
3.

Select Emulator Control View.
Input phone number (09010000001) into Incoming number.
Select SMS, input sending message (Hello Android) into Message,
then click [Send] button.

Input incoming number ・message
ex.
Incoming number : 09010000001
Select SMS
Message
: Hello Android

2

3
Send : Sending
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

162
4.6.7. Transmit SMS to emulator
4.

Confirm to be sure that message was transmitted from 09010000001
to emulator.

Notify “SMS receiving”

Message that sent into
Messaging application,
will be recorded.

4

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

163
4.6.8. Send position information to emulator
•

Send position information
1.
2.
3.
4.

Select Emulator Control view.
Open Manual tab, select Decimal.
Input Longitude/Latitude.
Click on [Send] button.

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

164
4.6.9. Other functions of emulator
• Acquire screenshots
1.
2.

When you click on [Screen Capture] button, screenshots of terminal
will be displayed on Device Screen Capture window.
Click [Save] button, then save file from Save window.
1
2

Preview display will be
displayed on Device
Screen Capture.

There are some
function including Save
as below:
Refresh : Re-acquire
Save
: Save
Done : Finish
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

165
4.6.9. Other functions of emulator
• Execute garbage collection
1.
2.

Select process that executed garbage collection from Devices View.
Click on [Cause GC] button in Heap View

2
1

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

166
4.6.9. Other functions of emulator
• Stop process
1.
2.

Select process that executed garbage collection from Devices View.
Click on [Stop Process] button in Devices View.
2

1

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

167
4.6.9. Other functions of emulator
• Acquire/Forward/Delete file within Terminal device
1.
2.

Select FileExplorer View.
Click on buttons correspond to operation (Acquire/Forward/Delete file)
1

File Explorer
Display file information within terminal
device.
Reference scope is limited because
there is limit access for real device.

2

: Retrieve file from terminal
: Forward file to terminal
: Delete file

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

168
5. Practice

This material is licensed under the Creative
Copyright 2009, Open Embedded Software Foundation, All rights reserved
Commons License BY-NC-SA 4.0.

169
5.1. Outline
How to practice?
• Learn how to develop Android application in 5 steps
Step 2: The method to make
screen transition
Step 1: The method to make
screen design
- Make menu screen

- Recognize “Button has been
clicked“
- Add screen in List format
- Use intent to make screen
transition

Step 4: Search database with
specific criteria & display data
in detail screen
- Receive and send parameters
between activities
- Make narrow search from database
- Set screen view properties from the
program

Step 3: SQLite database
operations & display data in list
format
- Create database and table
- Search data from database
- Display searching result in list
format

Step 5: How to create option
menu
- Add option menu to application
- Recognize “option menu
clicked”
- Display dialogue on screen

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

170
5.1. Outline
Preparation for practice
• Take skeleton project for practice in Eclipse.
– Storage place
• C:android_trainingskeleton_project
– Take 「RssReaderSkeleton1」in this folder.

– How to take it in?
• Start Eclipse, select 「Import」 from 「File」menu, display 「Import」 dialog.
• Select 「Existing Projects into Workspace」 from 「General」 in 「Import」
dialogue, and press 「Next」 button, specify then take root directory in
skeleton project in.
– Make a check mark in 「Copy projects into workspace」.

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

171
5.1. Outline
Practice application outline
• Create RSS Reader in practice
– RSS reader created in practice will acquire RSS feed ( information in XML
format) from internet and be saved in database. Search database, then
display RSS feed on screen.
Get RSS feed from
internet

Menu screen

Register RSS feed
into database.

Internet

Database

Search RSS feed
from database
After registration
into database
finished, display
dialogue.

List screen

Click “List display”
button

Select List
data

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

Detail screen

172
5.1. Outline
Practice application outline
• RSS reader screen and function outline
– RSS reader created in practice, is configured by 3 screens.
RSS reader

Start

①
Menu
screen

・・・ Direction of screen transition

②
List
screen

③
Detail
screen

#

Screen name

Function outline

1

Menu screen

• Start List screen
• Display option menu
• After clicking on option menu, get RSS feed from internet then register into
database
• After getting RSS feed, display Finish message on dialogue.

2

List screen

• Display RSS feed that is registered in database in List format.

3

Detail screen

• Display title, sending time, sender’s name, detail content of RSS feed that is
selected in List screen.
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

173
5.2. The method of making screen design
• Learn how to make screen design in Android application.
• Learn the following via practice.
– Method of making screen design using Layout editor.
– Method of creating string character resource file using Resource editor.

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

174
5.2. The method of making screen design
Create menu screen
• Method of making screen design using Layout editor.
– We can make screen design based on resource file in XML format in
Android application.
1. Resource file
Open (res/layout/main.xml),
start layout editor

2

(Refer to「4.2.1. Create resource file」for
Layout editor)

2. Display in Menu screen
Arrange 「List display」button
by Drag & Drop

1

Arrange 「Button」 from
「Views」 by Drag &
Drop

(Refer to「4.2.1. Create resource file」for
method of arranging button)

Use Layout editor to open
res/layout/main.xml

This material is licensedEmbedded Creative Commons License BY-NC-SA 4.0.
Copyright 2009, Open under the Software Foundation, All rights reserved

175
5.2. The method of making screen design
Create menu screen
3.

Use Properties View, set properties of arranged button.
–

Set id, layout_width, layout_height

3

3. Set id, height, width in
properties.
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

176
5.2. The method of making screen design
Create menu screen
• Setting value of properties
– id
• id that use when refers to View from program.
• Format of setting value
– @+id/<option id>

• Set example (In case of putting id that called ”a_button” on button)
– @+id/a_button

– layout_width
• Set the width of View
• Format setting value
– Numerical value +Unit
・・・ Specify by numerical value. Specify px, dip, etc … as for
unit.
– wrap_content ・・・ Fit the width of display character string, etc … in View.
– fill_parent
・・・ Fit automatically numerical value in new View.

– layout_height
• Set height of View
• Format of setting value is similar to layout_width
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

177
5.2. The method of making screen design
Create menu screen
• Confirm to be sure that the screen created in emulator will be
displayed.
– Select project in Android application, right-click then select 「Android
Application」 from 「Run As」.
Specify 「RssReader」project, and
right-click

Implement
application

Select 「Android Application」 from 「Run
As」 in menu that is displayed when
right –click
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

178
5.2. The method of making screen design
Create menu screen
• Use resource editor, set character string displayed on screen into character
string resource file (res/values/strings.xml).
–

We can collect character string that displayed on the screen into resource file in Android application.

■Character string resource file (res/values/strings.xml)

Add character string that
display on the screen into
character string resource file.

<?xml version="1.0" encoding=“utf-8"?>
<resources>
<string name=“app_name”> RssReader </string>
<string name=“go_to_list_page_button_label”> List Display</string>
</resources>

Refer to
character
string

■Resource file of screen design (res/layout/main.xml)
Refer to character string of character
<Button
string resource file from button
android:id="@+id/list_button"
properties.
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=“@string/go_to_list_page_button_label“
/>
This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

179
5.2. The method of making screen design
Create menu screen
• Refer to character string that display in button be disposed in
menu screen from character string resource file.
– Use resource editor, open character string resource file
(res/values/strings.xml).
– Add setting of button display character string into character string
resource file.
(Refer “4.3. Use resource besides design” for additional procedure)
– Use Layout Editor, open Screen design resource file (res/layout/main.xml),
use character string of character string resource file by character string of
button properties.
– Execute application, confirm to be sure that character string is displayed.

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

180
p
実 5.2. The method of making screen
r
習 Create menu screen
a
c
t Practice 1
i
c • Practice theme
– Create screen design of Menu screen.
e

design

• There is 1 button in Menu screen.
• Display “List Display” in the button.

This material is licensed under the Creative
Copyright 2009, Open Embedded Software Foundation, All rights reserved
Commons License BY-NC-SA 4.0.

181
p
実 5.2. The method of making screen design
r
習 Create menu screen
a
c
t Practice 1
i
c • Practice procedure
1. Open resource file (res/layout/main.xml) by Layout Editor, arrange
e
buttons in Menu screen.
2. Set properties (id, height, width) for arranged buttons.
3. Add “List Display” to character string displayed in button into character
string resource file (res/values/strings.xml).
4. Change setting of character string resource file that Text properties of
the button is set into “Reference”.

This material is licensed under the Creative
Copyright 2009, Open Embedded Software Foundation, All rights reserved
Commons License BY-NC-SA 4.0.

182
p
実 5.2. The method of making screen design
r
習 Create menu screen
a
c
t Practice 1
i
– Setting information 1
c
• Set the following value for View properties arranged in the screen.
e
#

2

View

Properties

1

1

LinearLayout

1. android:layout_width=“fill_parent”
2. android:layout_height=“fill_parent”

2

Button

1.
2.
3.
4.

android:id=“@+id/list_button”
android:layout_width=“fill_parent”
android:layout_height=“wrap_content”
android:text=“@string/go_to_list_page_button_label”

This material is licensed under the Creative
Copyright 2009, Open Embedded Software Foundation, All rights reserved
Commons License BY-NC-SA 4.0.

183
p
実 5.2. The method of making screen design
r
習 Create menu screen
a
c
t Practice 1
i
– Setting information 2
c
• Add the following value character string into character string resource file.
e
※ The format added into character string resource file will be
<string name=“Key”>Value</string>

Key

Value

Content

go_to_list_page_button_label

List display

Character string displayed in button 「List display」

This material is licensed under the Creative
Copyright 2009, Open Embedded Software Foundation, All rights reserved
Commons License BY-NC-SA 4.0.

184
p
実 5.2. The method of making
r
習 Create menu screen
a
c
t Practice 1
i
– Setting information 3
c
• Create the following resource file.
e
Screen
Menu screen

-

Resource file

screen design

Description

res/layout/main.xml
(Resource file)

• Arrange button “List display” in Menu screen

res/values/strings.xml
(Character string resource file)

• Add character string “List display” displayed in the
button “List display”.

This material is licensed under the Creative
Copyright 2009, Open Embedded Software Foundation, All rights reserved
Commons License BY-NC-SA 4.0.

185
p
実 5.2. The method of making screen design
r
習 Create menu screen
a
c
t Practice 1
i
c • Verification method
– Execute the practice application, make sure that “List display button” is
e
displayed.

This material is licensed under the Creative
Copyright 2009, Open Embedded Software Foundation, All rights reserved
Commons License BY-NC-SA 4.0.

186
p
実 5.2. The method of
r
習 Create menu screen
a
c
t Practice 1
i
c • Practice answer
– res/layout/main.xml
e

making screen design

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent“
>
<Button
android:id="@+id/list_button"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/go_to_list_page_button_label"
/>
</LinearLayout>

This material is licensed under the Creative
Copyright 2009, Open Embedded Software Foundation, All rights reserved
Commons License BY-NC-SA 4.0.

187
p
実 5.2. The method of
r
習 Create menu screen
a
c
t Practice 1
i
c • Practice answer
– res/values/strings.xml
e

making screen design

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">RssReader</string>
<string name="go_to_list_page_button_label"> List display </string>
</resources>

This material is licensed under the Creative
Copyright 2009, Open Embedded Software Foundation, All rights reserved
Commons License BY-NC-SA 4.0.

188
5.3. The method of screen transition
• Learn how to make screen transition in Android application
• Learn the following by practice
– The method of recognizing that “Button has been clicked”.
– The method of adding the screen in list format to application.
– The method of implementing screen transition used Intent class.

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

189
5.2. The method of making screen transition
Recognize “Button has been clicked”
• How to recognize “Button has been clicked”
– Mechanism
• When you click a button, “Event” will be created. Prepare “Event listener” to
recognize this event by program.
• Register “Event listener” that has been created beforehand to the button
that you want to recognize event.
• When event created by button, specified method will be retrieved.
Event listener
public void onClick(View view)
{

Click button

// Process

Event raised

}
Processing will
be executed

This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0.
Copyright 2009, Open under the Creative Foundation, All rights reserved

190
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic
Android Application Development Basic

Más contenido relacionado

La actualidad más candente

Eclipse Mobile Tools for Java Project
Eclipse Mobile Tools for Java ProjectEclipse Mobile Tools for Java Project
Eclipse Mobile Tools for Java ProjectDavid Marques
 
Setting up a vscode development environment for mbed 5 application using the ...
Setting up a vscode development environment for mbed 5 application using the ...Setting up a vscode development environment for mbed 5 application using the ...
Setting up a vscode development environment for mbed 5 application using the ...Steve Mylroie
 
Os eclipse-androidwidget-pdf
Os eclipse-androidwidget-pdfOs eclipse-androidwidget-pdf
Os eclipse-androidwidget-pdfweerabahu
 
Android Localization
Android LocalizationAndroid Localization
Android LocalizationKaran Geddam
 
Introduction to Android Development Latest
Introduction to Android Development LatestIntroduction to Android Development Latest
Introduction to Android Development LatestProf. Erwin Globio
 
Software training report
Software training reportSoftware training report
Software training reportNatasha Bains
 
Basics of Android
Basics of Android Basics of Android
Basics of Android sabi_123
 
グローバルサイン証明書This software
グローバルサイン証明書This softwareグローバルサイン証明書This software
グローバルサイン証明書This softwareHISASHI MIYAGI
 
Using JavaScript to Build HTML5 Tools (Ian Maffett)
Using JavaScript to Build HTML5 Tools (Ian Maffett)Using JavaScript to Build HTML5 Tools (Ian Maffett)
Using JavaScript to Build HTML5 Tools (Ian Maffett)Future Insights
 
Industrial Training in Android Application
Industrial Training in Android ApplicationIndustrial Training in Android Application
Industrial Training in Android ApplicationArcadian Learning
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentIJERD Editor
 
O uso de tecnologias Intel na implantação de sistemas de alto desempenho
O uso de tecnologias Intel na implantação de sistemas de alto desempenhoO uso de tecnologias Intel na implantação de sistemas de alto desempenho
O uso de tecnologias Intel na implantação de sistemas de alto desempenhoIntel Software Brasil
 

La actualidad más candente (14)

Eclipse Mobile Tools for Java Project
Eclipse Mobile Tools for Java ProjectEclipse Mobile Tools for Java Project
Eclipse Mobile Tools for Java Project
 
Setting up a vscode development environment for mbed 5 application using the ...
Setting up a vscode development environment for mbed 5 application using the ...Setting up a vscode development environment for mbed 5 application using the ...
Setting up a vscode development environment for mbed 5 application using the ...
 
Os eclipse-androidwidget-pdf
Os eclipse-androidwidget-pdfOs eclipse-androidwidget-pdf
Os eclipse-androidwidget-pdf
 
Multi-OS Engine Technology Overview
Multi-OS Engine Technology OverviewMulti-OS Engine Technology Overview
Multi-OS Engine Technology Overview
 
Android Localization
Android LocalizationAndroid Localization
Android Localization
 
Android Development Basics
Android Development BasicsAndroid Development Basics
Android Development Basics
 
Introduction to Android Development Latest
Introduction to Android Development LatestIntroduction to Android Development Latest
Introduction to Android Development Latest
 
Software training report
Software training reportSoftware training report
Software training report
 
Basics of Android
Basics of Android Basics of Android
Basics of Android
 
グローバルサイン証明書This software
グローバルサイン証明書This softwareグローバルサイン証明書This software
グローバルサイン証明書This software
 
Using JavaScript to Build HTML5 Tools (Ian Maffett)
Using JavaScript to Build HTML5 Tools (Ian Maffett)Using JavaScript to Build HTML5 Tools (Ian Maffett)
Using JavaScript to Build HTML5 Tools (Ian Maffett)
 
Industrial Training in Android Application
Industrial Training in Android ApplicationIndustrial Training in Android Application
Industrial Training in Android Application
 
International Journal of Engineering Research and Development
International Journal of Engineering Research and DevelopmentInternational Journal of Engineering Research and Development
International Journal of Engineering Research and Development
 
O uso de tecnologias Intel na implantação de sistemas de alto desempenho
O uso de tecnologias Intel na implantação de sistemas de alto desempenhoO uso de tecnologias Intel na implantação de sistemas de alto desempenho
O uso de tecnologias Intel na implantação de sistemas de alto desempenho
 

Similar a Android Application Development Basic

Basic Android College Seminar Presentation
Basic Android College Seminar Presentation Basic Android College Seminar Presentation
Basic Android College Seminar Presentation Jimmin Kurichiyil
 
PRESENTATION ON ANDROID
PRESENTATION ON ANDROIDPRESENTATION ON ANDROID
PRESENTATION ON ANDROIDRajat Kumar
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android WorkshopOpersys inc.
 
Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA NITIN GUPTA
 
Embedded Android Workshop at Embedded World 2014
Embedded Android Workshop at Embedded World 2014Embedded Android Workshop at Embedded World 2014
Embedded Android Workshop at Embedded World 2014Opersys inc.
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android WorkshopOpersys inc.
 
Android Seminar BY Suleman Khan.pdf
Android Seminar BY Suleman Khan.pdfAndroid Seminar BY Suleman Khan.pdf
Android Seminar BY Suleman Khan.pdfNomanKhan869872
 
Sogeti - Android tech track presentation - 24 february 2011
Sogeti - Android tech track presentation - 24 february 2011Sogeti - Android tech track presentation - 24 february 2011
Sogeti - Android tech track presentation - 24 february 2011Kenneth van Rumste
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android WorkshopOpersys inc.
 
Embedded Android Workshop at ABS 2014
Embedded Android Workshop at ABS 2014Embedded Android Workshop at ABS 2014
Embedded Android Workshop at ABS 2014Opersys inc.
 
Android Training Course In Chandigarh
Android Training Course In ChandigarhAndroid Training Course In Chandigarh
Android Training Course In ChandigarhExcellence Academy
 
Qa extreme 2011 eran kinsbruner
Qa extreme 2011 eran kinsbrunerQa extreme 2011 eran kinsbruner
Qa extreme 2011 eran kinsbrunerEran Kinsbrunner
 

Similar a Android Application Development Basic (20)

Android introduction
Android introductionAndroid introduction
Android introduction
 
Basic Android College Seminar Presentation
Basic Android College Seminar Presentation Basic Android College Seminar Presentation
Basic Android College Seminar Presentation
 
Android technology
Android technology Android technology
Android technology
 
PRESENTATION ON ANDROID
PRESENTATION ON ANDROIDPRESENTATION ON ANDROID
PRESENTATION ON ANDROID
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
 
Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA Android Application Development Training by NITIN GUPTA
Android Application Development Training by NITIN GUPTA
 
Embedded Android Workshop at Embedded World 2014
Embedded Android Workshop at Embedded World 2014Embedded Android Workshop at Embedded World 2014
Embedded Android Workshop at Embedded World 2014
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
 
Android tutorial beginner
Android tutorial beginnerAndroid tutorial beginner
Android tutorial beginner
 
Android Seminar BY Suleman Khan.pdf
Android Seminar BY Suleman Khan.pdfAndroid Seminar BY Suleman Khan.pdf
Android Seminar BY Suleman Khan.pdf
 
Sogeti - Android tech track presentation - 24 february 2011
Sogeti - Android tech track presentation - 24 february 2011Sogeti - Android tech track presentation - 24 february 2011
Sogeti - Android tech track presentation - 24 february 2011
 
Android
AndroidAndroid
Android
 
Embedded Android Workshop
Embedded Android WorkshopEmbedded Android Workshop
Embedded Android Workshop
 
Android Basic PPT
Android Basic PPTAndroid Basic PPT
Android Basic PPT
 
Embedded Android Workshop at ABS 2014
Embedded Android Workshop at ABS 2014Embedded Android Workshop at ABS 2014
Embedded Android Workshop at ABS 2014
 
Android Applications
Android ApplicationsAndroid Applications
Android Applications
 
Android ppt
Android pptAndroid ppt
Android ppt
 
Android ppt
Android ppt Android ppt
Android ppt
 
Android Training Course In Chandigarh
Android Training Course In ChandigarhAndroid Training Course In Chandigarh
Android Training Course In Chandigarh
 
Qa extreme 2011 eran kinsbruner
Qa extreme 2011 eran kinsbrunerQa extreme 2011 eran kinsbruner
Qa extreme 2011 eran kinsbruner
 

Más de OESF Education

Android組み込み開発テキスト pandaboard es編
Android組み込み開発テキスト pandaboard es編Android組み込み開発テキスト pandaboard es編
Android組み込み開発テキスト pandaboard es編OESF Education
 
Android UIデザイン入門
Android UIデザイン入門Android UIデザイン入門
Android UIデザイン入門OESF Education
 
Android™組込み開発基礎コース BeagleBoard編
Android™組込み開発基礎コース BeagleBoard編Android™組込み開発基礎コース BeagleBoard編
Android™組込み開発基礎コース BeagleBoard編OESF Education
 
Androidプログラミング入門
Androidプログラミング入門Androidプログラミング入門
Androidプログラミング入門OESF Education
 
Androidタブレットアプリケーション開発入門
Androidタブレットアプリケーション開発入門Androidタブレットアプリケーション開発入門
Androidタブレットアプリケーション開発入門OESF Education
 
Androidアプリケーション応用 WebAPI開発
Androidアプリケーション応用 WebAPI開発Androidアプリケーション応用 WebAPI開発
Androidアプリケーション応用 WebAPI開発OESF Education
 
Androidアプリケーション開発入門
Androidアプリケーション開発入門Androidアプリケーション開発入門
Androidアプリケーション開発入門OESF Education
 
Android組込み開発基礎コース Armadillo-440編
Android組込み開発基礎コース Armadillo-440編Android組込み開発基礎コース Armadillo-440編
Android組込み開発基礎コース Armadillo-440編OESF Education
 
Android アプリケーション開発応用
Android アプリケーション開発応用Android アプリケーション開発応用
Android アプリケーション開発応用OESF Education
 

Más de OESF Education (9)

Android組み込み開発テキスト pandaboard es編
Android組み込み開発テキスト pandaboard es編Android組み込み開発テキスト pandaboard es編
Android組み込み開発テキスト pandaboard es編
 
Android UIデザイン入門
Android UIデザイン入門Android UIデザイン入門
Android UIデザイン入門
 
Android™組込み開発基礎コース BeagleBoard編
Android™組込み開発基礎コース BeagleBoard編Android™組込み開発基礎コース BeagleBoard編
Android™組込み開発基礎コース BeagleBoard編
 
Androidプログラミング入門
Androidプログラミング入門Androidプログラミング入門
Androidプログラミング入門
 
Androidタブレットアプリケーション開発入門
Androidタブレットアプリケーション開発入門Androidタブレットアプリケーション開発入門
Androidタブレットアプリケーション開発入門
 
Androidアプリケーション応用 WebAPI開発
Androidアプリケーション応用 WebAPI開発Androidアプリケーション応用 WebAPI開発
Androidアプリケーション応用 WebAPI開発
 
Androidアプリケーション開発入門
Androidアプリケーション開発入門Androidアプリケーション開発入門
Androidアプリケーション開発入門
 
Android組込み開発基礎コース Armadillo-440編
Android組込み開発基礎コース Armadillo-440編Android組込み開発基礎コース Armadillo-440編
Android組込み開発基礎コース Armadillo-440編
 
Android アプリケーション開発応用
Android アプリケーション開発応用Android アプリケーション開発応用
Android アプリケーション開発応用
 

Último

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxLoriGlavin3
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 

Último (20)

Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
The State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptxThe State of Passkeys with FIDO Alliance.pptx
The State of Passkeys with FIDO Alliance.pptx
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 

Android Application Development Basic

  • 1. Android Application Development Basic Training This material is licensed under the Creative Commons License BY-NC-SA 4.0. Ver1.02(01)
  • 2. About usage of this Textbook ・ This textbook is licensed under the Creative Commons License BY-NC-SA 4.0. It is prohibited to use this material for business use otherwise you are OESF member or OESF education consortium member. ・This training program, includes entire of training materials, will be provided without any guarantee from OESF. OESF has no responsibility if it occurred damages or legal violation behaviors which be caused of using or misusing any content or detail information of this course. This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 3. Purpose of Training • Equip the necessary knowledge for developing application based on Android. – – – – The functions provided by Android Environment development The usage of Development Tools How to implement/debug the Application • Experience application development through practice exercises. This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 4. Training Schedule • The 1st day – – – – Chapter 1 : Chapter 2 : Chapter 3 : Chapter 4 : What is Android? The architecture of Android Application Environment development preparation Tutorial • The 2nd day – Chapter 5 : Practice exercises – Chapter 6 : Training summarize This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 5. Skill requirement to attend training course • Have experience in Java – Actually use Java to do programming in practice exercises in the 2nd day. – Have understanding of basic Java language specification. • Have experience in using Eclipse – Using Eclipse to practice exercises. This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 6. 1. What is Android? This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 7. Chapter 1: Overview • • • • • • What is Android? Why has Android attracted attention? What can you do with Android? Android from the technical aspect Application development environment How to distribute Applications? This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 8. 1.1. What is Android? • Android is – Platform for Mobile devices – Mainly used as Platform for Mobile phones • The history of Android Date Content 10/2003 Android Company established 08/2005 Google bought Android Company 11/2007 Open Handset Alliance (OHA) established Development Tool Android SDK 1.0 released 10/2008 Started to sell loading Android- Smart Phone 「T-Mobile G1」 in the world 04/2009 Development Tool Android SDK 1.5r1 released 05/2009 Development Tools Android SDK 1.5r2 released 07/2009 NTT Docomo started to sell Android Mobile 「HT-03A」 in Japan Development Tool Android SDK 1.5r3 published This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 9. 1.1. What is Android? • The history of Android (Continue) Date Content 09/2009 Development Tool Android SDK 1.6 published 10/2009 Development Tool Android SDK 2.0 published 01/2010 Development Tool Android SDK 2.1 published 05/2010 Development Tool Android SDK 2.2 published 12/2010 Development Tool Android SDK 2.3 published (Gingerbread) 02/2011 Development Tool Android SDK 2.3.3 published Development Tool Android SDK 3.0 published (Honeycomb) This material is licensedEmbedded Creative Commons License BY-NC-SA 4.0. Copyright 2009, Open under the Software Foundation, All rights reserved 9
  • 10. 1.1. What is Android? • The main organizations related to Android Organization Name Overview Open Handset Alliance (OHA) • This organization was established to promote popularization of Android. Organize the activities of compatible handsets/software development and services popularization. • Android specifications settlement, deliverables control are done by the OHA. • 71 companies joined (until 05/2010) such as T-mobile (USA), Motorola (USA), NTT Docomo (Japan), etc… • http://www.openhandsetalliance.com/index.html Open Embedded Software Foundation (OESF) • This organization was established to develop and popularize the common framework, platform for Android based Embedded System. • Working groups that are organized according to business fields take the lead in implementing activities. • 75 companies joined (until 05/2010) • http://www.oesf.jp This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 11. 1.2. Why has Android attracted attention? • At the present, Android has attracted a lot of attention – How much attention has it attracted? • Android based hardware are being continuously launched to the market. Hardware Overview Mobile Phone 05/2009 NTT Docomo launched HT-03A (HTC Magic) 06/2009 HTC (Taiwan) launched HTC Hero 07/2009 T-Mobile myTouch 3G was on sale 01/2010 Google NEXUS ONE was on sale 04/2010 NTT Docomo Xperia was on sale Media Player Creative Zii EGG was on sale This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 12. 1.2. Why has Android attracted attention? • At the present, Android has attracted a lot of attention. – How much attention has it attracted? • The number of web search about Android from the second haft of 2008 has been increasing. (Google Trend Research) ■ Major Events A: T-Mobile G1 on sale Android Market opened B: OHA released Android SDK 2.0 C: Google Nexus One on sale D: Small size version of Sony Ericsson Xperia X10 on sale E: Microsoft criticized for patent infringement of Android This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 13. 1.2. Why has Android attracted attention? • There are 4 reasons why Android receives much attention 1. Android is available for free, which is expected to reduce cost for development platform. 2. Everyone can get Development Tools, Technical documents and Source code in free. 3. The training cost is low if you know the Java SE. 4. Being deployed in embedded development field besides Mobile Phone. This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 14. 1.2. Why has Android attracted attention? • Android is available for free, which is expected to reduce cost for development platform. – Expense for development platform is expected to reduce by adopting Android platform. ※Development software combined with hardware, such as Driver, is necessary. Reduced cost Application Development Fee Platform Development Fee Hardware Development Fee Before use Android After use Android This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 15. 1.2. Why has Android attracted attention? • Everyone can get Development Tools, Technical documents and source code in free – Under Apache License 2.0, Android’s documents, source code have been published openly. • The source of Proprietary modules such as driver, GoogleMapsAPI is not provided. – Development Tools are freely received from OHA. This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 16. 1.2. Why has Android attracted attention? • The training cost is low if you know the Java SE – Because Android Application can be developed by Java SE and Eclipse: • It is unnecessary for learning development language if you know Java language. • The cost of learning how to use Development Tools is low for the developer who has used Eclipse. This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 17. 1.2. Why has Android attracted attention? • Being deployed in embedded development field besides Mobile Phone – Besides Mobile phone, the utilization on various equipments is being researched and developed • Besides Mobile phone, some hardware which Android has been transplanted into are: – Net book – Navigation System (Car Navi, etc.) – TV Recorder (Record/play Digital broadcast) – Other digital home appliances » Be exhibited many times in the Embedded System development technology Expo (ESEC2010) This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 18. 1.3. What can you do with Android? • Developer can create the applications that using the following functions provided by Android – View Website by Full browser – Drawing 2D/3D Graphic – Show/Play sound, image, still media • Corresponding format (MPEG4, H.264, MP3, AAC, AMR, JPG, PNG, GIF) – – – – – – Voice call by GSM (2G), 3G Data transmission by Bluetooth, EDGE, WiFi Camera (still image/ video) GPS Various sensors Data storage by SQLite This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 19. 1.3. What can you do with Android? • Sensor devices that can be controlled by Android # Sensor Name Overview 1 Acceleration sensor Detect acceleration 2 Tilt sensor Detect azimuth, inclination (the above and below slope of horizontal condition), rotation angle (the left and right slope of horizontal condition) 3 Temperature sensor Detect temperature 4 Magnetic sensor Detect magnetic 5 Light sensor Detect light 6 Approach sensor Detect the distance between objects 7 Gyroscope Detect angular velocity 8 Pressure sensor Detect the pressure put on real machine ※ Need the hardware when using sensors This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 20. 1.3. What can you do with Android? • Introduce Android applications Web Browser Telephone This material is licensed under the Creative Commons License BY-NC-SA 4.0. Google Maps
  • 21. 1.3. What can you do with Android? – Using Web Browser 1. View weather information – Use Google Weather API to view weather information ① – Input Japanese (IME) 2. Simeji – Software keyboard allows Flick input ※ Flick input is a method that input to chose character by slide the key of software keyboard ② This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 22. 1.3. What can you do with Android? – Using sensors 3. 4. Google Sky Map – Use inclination sensor and acceleration sensor to view the night sky in the direction toward the terminal Labyrinth lite – The game uses inclination sensor ③ – Using camera 5. Layer – Browser displays the digital information of the reality picture taken by camera This material is licensed under the Creative Commons License BY-NC-SA 4.0. ④ ⑤
  • 23. 1.4. Android from the technical aspect • The execution environment for Android applications – Android applications run on Android run-time virtual machine – Linux has adopted as Android run-time platform, the applications run on Linux Software(Android Platform) Application Application Android Runtime Linux kernel Hardware This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 24. 1.4. Android from the technical aspect •Android is composed of 5 elements Components of Android Application ⑤ Home Address Call Application Browser Application framework ④ Activity Window manager Content provider View system Package management Acknowledgement management Call management Resource management Position management Sensor management Library ② Surface manager libc Media framework SQLite OpenGL I ES FreeType Webkit Android run-time SGL SSL ① ③ Core library Dalvik VM Linux kernel Display driver Bluetooth driver Camera driver Flash memory driver Binder ( IRC) Keypad driver USB driver Hardware This material is licensed under the Creative Commons License BY-NC-SA 4.0. WiFi driver Audio driver Electric power management
  • 25. 1.4. Android from the technical aspect • Components overview ①.Linux kernel • Linux kernel is based on Linux 2.6 and added some Android features • Include the hardware that provides the necessary functions to run applications ②.Library • Library is created by C/C++ – Webkit (Web browser Draw), SQLite (Database), OpenGL/SE (3D draw), … • Library is used through application framework by application. ③.Android runtime • The execution environment of Android applications • Core Java Libraries includes Virtual machine execution environment (Dalvik VM) This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 26. 1.4. Android from the technical aspect • Components overview ④. Application Framework • Provides necessary Java API to use applications behavior/operation and Libraries ⑤. Application • Android applications are developed by using application framework – Such as: Telephone, Web browser, Address book, etc… This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 27. 1.4. Android from the technical aspect • The lightweight runtime environment for Mobile – Dalvik virtual machine (Dalvik VM) • Optimization of Java VM for small-memory environment – Google has developed its own virtual machine – Be designed to allow simultaneity execution of multiple applications even in low-memory environment – Dalvik executables format (.dex) • In Dalvik VM, the standard .class, .jar are converted into .dex to run • Compare with .class, the memory size used when running is small Java VM .class Dalvik VM convert .dex .jar This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 28. 1.4. Android from the technical aspect – Dalvik VM is not compatible with Java VM • The binary format of Executable files are different – In Dalvik VM, file format .class, .jar can not run – In Java VM, file format .dex can not run Java VM Dalvik VM .class .dex .jar This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 29. 1.4. Android from the technical aspect • If there is no comparison about portable limit, Android applications is almost the same with Java applications operating on PC. i - Application (Doja-5.x)※1 Android Application Java support Java ME Java SE Application size limit 1MB (depend on model) None Heap memory limit 6MB~15MB (depend on models) 16MB (SDK setting value) ※2 Transmit limit Unable to transmit except application download origin None HTTP transmit size limit Request body: 80KB Response body: 150KB None Cookies Available with model released from 2009 summer Available Character code SJIS UTF-8 Persistence method ScratchPad File, SQLite ※1. i - Application Content Development Guide for Doja-5.x/5.x LE~ Detail Part ~Version 3.00 ※2. Default setting value in SDK, may be changed according to models. Fro example, Nexus One is 24MB. This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 30. 1.5. Application development environment Item Necessary environment OS Windows XP, Windows Vista (32 / 64 bit) From Mac OS X 10.5.8 onwards (x86 only) Linux (already tested on Ubuntu Hardy Herson) Java SDK Java SDK 5, Java SDK 6 Android Development Tools Android SDK Integrated Development Environment Eclipse 3.4 (Ganymede), 3.5 (Galileo) Android Development Tools (ADT) Plug-in Text-based Development environment Apache Ant (From Windows version 1.7, Mac/Linux version 1.6.5 onwards)  Actual equipment is not required. Emulator for development is available.  Emulator may have some parts (such as sensor, etc.) unavailable. Refer for details: http://developer.android.com/intl/ja/sdk/requirements.html This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 31. 1.6. How to distribute Applications? • There are 2 main ways to distribute Applications – Distribute via Android Market – Distribute without using Android Market ※ What is Android Market? – Is a Website for distribution/sale Android Applications – Is a common way to distribute Android Applications This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 32. 1.6. How to distribute Applications? • Distribute via Android Market site – Distribution process 1. Register Developer account on Android Market site – To register Developer account, you must have Google account 2. Create digital certificate for Applications※1 – Use Keytool (includes Java SDK) ※2 to create certificate 3. Applications must be digitally signed※1 – Use jarsigner (includes Java SDK) ※2 to make digital signature 4. Upload Applications onto Android Market ※1 Can create certificate, make sign by Eclipse functions ※2 Refer Tools manual to know the Tools usage – Requirement • Google Account This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 33. 1.6. How to distribute Applications? • Distribute via Android Market site – Process of register Developer account on Android Market site 1. Register developer profile on Developer registration site – Registration Site » http://market.android.com/publish/signup – Input Profile items » » » » 2. 3. Name Mail address (need Google Account) Web site URL Phone number Payment for registration ($25) – Can payment with Credit card via Google checkout Agree with Distribution Agreement This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 34. 1.6. How to distribute Applications? • Distribute without using Android Market site – Distribute Application Files directly • Example – Distribute Files via Homepage – Distribute Files by CD, USB memory, … – Distribute Files over network such as LAN environments • Distribution process 1. Create digital certificate for Applications 2. Digitally sign Applications 3. Distribute Application Files • Installation method 1. Using Android terminals to download and install files 2. Connect USB with PC and Android terminal, use install command to install This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 35. 1.6. How to distribute Applications? • Distribute without using Android Market site – Installation Method ① Using Android terminals to download and install Application files • Process 1. Use browser of Android Terminal to download Application file 2. After the download is completed, click on the Application file on download history 3. Press “Install” on Install confirmation screen This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 36. 1.6. How to distribute Applications? • Distribute without using Android Market site – Installation Method ① Click on file Click on Download file Click on Install button Step 1 Step 2 This material is licensed under the Creative Commons License BY-NC-SA 4.0. Step 3
  • 37. 1.6. How to distribute Applications? • Distribute without using Android Market site – Installation Method ② Connect USB with PC and Android terminal, use Install command to install • Process 1. 2. Use USB cable to connect PC and Android terminal Start Command prompt, execute adb install command >adb install < Application file name(.apk)> ■Install Input Command Prompt( C:Simeji3.0.6.apk )by USB C:>adb install C:Simeji3.0.6.apk // ・・・ Step 1 596 KB/s (1413225 bytes in 2.312s) pkg: /data/local/tmp/Simeji3.0.6.apk Success // ・・・ Step 2 This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 38. 2. Android Application Architecture This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 39. Chapter 2: Overview • Main components • Life cycle • The security of Android This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 40. 2.1. Main components • The components of Android are available to achieve key features of application Key features of a common Application User interface Inter-process communication Activity Intent External communication File Access Perform Background Actualize Content Provider Main components of Android This material is licensed under the Creative Commons License BY-NC-SA 4.0. Broadcast Receiver Service
  • 41. 2.1. Main components • There are 5 basic components: 1. 2. 3. 4. 5. Activity Intent Broadcast Receiver Service Content Provider This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 42. 2.1.1. Activity • What is Activity? – The Android application screen is created by placing many parts such as Button, Checkbox, … on Activity – One screen is composed of one activity – Activity has running and pausing status This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 43. 2.1.1. Activity • The Android application screen is created by placing many parts such as Button, Checkbox, … on Activity ① ② The left figure is activity which view (button) placed on 1. Activity 2. View (button) The left figure screen is shown in the following configuration 2. View ( button) 1. Activity This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 44. 2.1.1. Activity • Can handle to respond to user input screen – On screen, the information of operation (Ex: click on button) will be notified to Activity via View – Activity can handle to respond to the notification • Ex: after click on the button 3.Execute the handler when button clicked 1. Click on button Button 2.Notify Activity public void onClick(View view) { // View message on screen } This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 45. 2.1.1. Activity • One screen is composed of one activity – For Application has multiple screens, the number of activities is equal to the number of screens. Application Application Activity Activity Activity Activity The Application is composed by 1 screen The Application is composed by 3 screens This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 46. 2.1.1. Activity • Activity displayed mechanism – On screen, at one time, only one activity is displayed • In Android Application, even if there are many activities, only 1 activity can be displayed • For display new Activity, previous activity is hidden, new activity is displayed on above This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 47. 2.1.1. Activity • There are several states of activity, the state is changed by operation • State of activity has defined in 3 types: 1. Foreground status • When activity is being displayed, the cursor is in working condition 2. Background status • Activity is in hidden condition by another activity 3. Visible status • When no activity screen is displayed (dialog…), the activity cursor is in losing condition (activity is being displayed over dialog) This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 48. 2.1.1. Activity • The kind of activity is used depend on the type of screen – Example of Activity # Screen Using Activity class 1 Single Screen Activity class 2 List display Screen ListActivity class 3 Map Screen (Google Map) MapActivity class 1. Single Screen (use Activity) 2. List display Screen (use ListActivity) This material is licensed under the Creative Commons License BY-NC-SA 4.0. 3. Map Screen (use MapActivity)
  • 49. 2.1.2. View • What is View? – Buttons, checkboxes, spinners, … – The View that contains other views is called ViewGroup • The relation of Activity, View and ViewGroup User Interface View View ViewGroup View ViewGroup Activity This material is licensed under the Creative Commons License BY-NC-SA 4.0. View
  • 50. 2.1.2. View • Typical View View name Overview TextView Display text Button Basic press button EditText Input text CheckBox The button has ON/OFF status Spinner This button for choose one item from the list AnalogClock Analog Clock This material is licensed under the Creative Commons License BY-NC-SA 4.0. Image
  • 51. 2.1.2. View • Typical ViewGroup Name Overview LinearLayout • The ViewGroup that view is placed in horizontal or vertical direction • Display scroll bar in case it’s not fit in screen TableLayout • The ViewGroup that view is placed in grid (similar HTML table tags) • TableRow is specified inside TableRow • The ViewGroup that view is placed in Table line ListView • The ViewGroup that view is placed in one list • Display scroll bar in case it’s not fit in screen TabHost • The ViewGroup that display is replaced by switching tabs This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 52. 2.1.2. View • Can create the original view (Custom Views) – Custom Views can be created in 3 ways • Extending an existing View – Effective way if you want to add functionally into an existing View • Inherit from basic class (android.view.View) – If you want to create a completely new View – Possible for develop a View in most freedom – Require deep knowledge of basic class for implementation from scratch • Combine existing Views, ViewGroups to create a new View ■ For more detail, please refer Android Developers in Development Guide http://developer.android.com/intl/ja/guide/topics/ui/custom-components.html This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 53. 2.1.3. Intent • What is intent? – The mechanism to request a process and to exchange message between components • The components can use intent are activity, broadcast receiver and service – Example: • Start activity B from activity A (screen transition) • Send request “call phone” from Address book application to Make call application This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 54. 2.1.3. Intent • Call out component by intent: the intent containing the information of caller component give call out request for Android – The sample of calling out B component from A component This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 55. 2.1.3. Intent • There are 2 ways in using intent: using explicit intents and using implicit intents – Using Explicit intents • This way is used in case of called component is designated its name directly. It is used to call out components in the same application (such as screen transition) – The sample of calling out designated component This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 56. 2.1.3. Intent – Using Implicit intents • This way is used in case of the called component is not designated (named), only specify action (Sample in under figure: specify to “make a telephone call”). Often used to call out components in other Applications (such as other Application screen) • From configuration information of components, Android will determine which component be started. – The sample of calling out an specified action This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 57. 2.1.3. Intent – Using Implicit intents (continuous) • When using Implicit intents, by cooperating with Android’s applications, the following tasks can be done – Phone Application » Open Dial window of specified number – Address book Application » Display address book list » Display information of 1 address in address book » Edit information of specified address – Web browser » Use Browser to display the URL address of specified Website This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 58. 2.1.3. Intent – Using Implicit intents (continuous) • Implicit intents can send broadcast for whole system • Intents sent by sending broadcast (broadcasted intent) is used to report the change with condition, such as “Complete system startup”, “Change battery occurred”, … • Intents sent by sending broadcast (broadcasted intents) are intents that can receive only Broadcast receivers. This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 59. 2.1.4. Broadcast receiver • What is Broadcast receiver? – Broadcast receiver is a mechanism for responding with intents sent by sending broadcast – Can create peculiar Broadcast receiver by inheriting BroadcastReceiver class This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 60. 2.1.4. Broadcast receiver • Example of using Broadcast receiver – Check mail when starting up Android terminal 1. 2. Receive broadcast intent when Android terminal startup complete by Broadcast receiver Broadcast receiver call out Mail check service ※ Although mail check process can be executed from Broadcast receiver directly, but it’s more efficient when using Service to deal with time-consuming ① Complete startup message Intent ② Execute Mail check service Broadcast receiver Intent Send broadcast intent Receive intent This material is licensed under the Creative Commons License BY-NC-SA 4.0. Mail check service
  • 61. 2.1.4. Broadcast receiver • Can use Broadcast receiver to create a process started by system notification – Define the action of broadcast intent (some excerpts) # Constant name of Intent class Condition Setting value 1 ACTION_BOOT_COMPLETED Completed system startup android.intent.action. BOOT_COMPLETED 2 ACTION_TIME_CHANGED Time set up android.intent.action.TIME_SET 3 ACTION_TIMEZONE_CHANGED The time zone is changed android.intent.action.TIMEZONE_CHANGED 4 ACTION_PACKAGE_ADDED The Application is new installed android.intent.action. PACKAGE_ADDED 5 ACTION_PACKAGE_REMOVED The Application is uninstalled android.intent.action. PACKAGE_REMOVED 6 ACTION_BATTERY_CHANGED Whether charging, the battery is changed android.intent.action. BATTERY_CHANGED ■ Please refer more setting value at the following URL http://developer.android.com/intl/ja/reference/android/content/Intent.html This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 62. 2.1.5. Service • What is service? – The mechanism to execute a process by independent thread – Service and foreground’s activity are executed in separate threads. Therefore, the process can continuous even if an interrupt occurred with other activities. Play music (not use Service) Play music (use Service) The difference in operating when Activity interrupt occurred by receiving mail in case of playing music directly from Activity or through service. This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 63. 2.1.5. Service • Introduction about application which used service – DroidTracker: The application for sending location information get by GPS through SMS, mail, twitter.  Processing location information acquisition by GPS function through Service.  Processing SMS, mail, twitter sending functions through Service. This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 64. 2.1.6. Content provider • What is Content provider? – The mechanism that allows the application that holding data can be accessed (search, insert, update, delete) from other applications – Example • Access phone call log from application • Insert Website into browser bookmarks from application ※ Data means the information that is persisted in files, database of application This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 65. 2.1.6. Content provider • Why content provider must be used to access to other applications’ data? – The data kept in application can not be access directly from external applications Security wall Application Get information External Applications Storage Edit information This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 66. 2.1.6. Content provider • Content provider has mechanism to realize/achieve the access from external applications Security wall Application Content provider Get information External Applications Storage Edit information This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 67. 2.1.6. Content provider • In order to achieve a secure access, content provider will settle the interfaces – Main interfaces # Event name Content 1 Query Search data, then return searching results 2 Insert Insert data 3 Update Update data 4 Delete Content provider Delete data This material is licensed under the Creative Commons License BY-NC-SA 4.0. Interface is settled query insert update delete External Applications
  • 68. 2.1.6. Content provider • In Android, depend on content provider, data has been published – Published data • • • • • • • Phone call log Contact list Browser Bookmarks Browser Search history Images in Media Pictures in Media Audio in Media This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 69. 2.2. Life cycle • What is Life cycle? – In Activity and Service, Life cycle is defined as the life cycle of object from creation until destruction. Activity Life cycle Service Life cycle This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 70. 2.2.1. Activity Life cycle • Activity Lifecycle – 3 types of status transition are determined in an activity (Foreground, background, visible) – When status change occurs, Event will be notified. This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 71. 2.2.1. Activity Life cycle • Life cycle includes notified events This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 72. 2.2.1. Activity Life cycle • In an Activity, the following events are notified. The developers can create a process to respond to these notifications – Notified events # Events name Content 1 onCreate The event occurs in the initial startup 2 onStart The event occurs just before the activity is displayed 3 onResume The event occurs just before the activity is available (active status) 4 onPause The event occurs just before the activity becomes visible 5 onStop The event occurs in case of unused status for a while after onPause (The event may not occur when lack of memory) 6 onRestart The event occurs when stopped activity is showed again 7 onDestroy The event occurs just before the activity is annulled (The event may not occur when lack of memory) This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 73. 2.2.1. Activity Life cycle • Notes about Activity notification event – Not ensure that onStop, onDestroy are always be notified • In case memory run out, Android will stop unused application processes forcedly • In this case, onStop, onDestroy notifications in Activity Life cycle can not be ensured • In case it’s a absolute necessary process, use onPause to processing The transition route in case of memory run out This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 74. 2.2.2. Service Life cycle • The Service Life cycle is defined as the right figure • For an event is notified when changing state like in Activity, the process to respond to notifications can be created # Events name Content 1 onCreate The event occurs in the first startup 2 onStart The event occurs just before the Service is started 3 onDestroy The event occurs just before the Service is destroyed This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 75. 2.3. Android Security • To use the functions of Hardware such as network, camera, … the permission to use information of each application must be set – The operations that can affect on OS, application, user data, … are restricted in Application This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 76. 2.3. Android Security • The method of setting application use permission 1. Insert uses-permission tags in AndroidManifest.xml 2. Set the set value of Permission Function in android:name ※ In below sample: Permit an application to connect to the Internet ■ Setting sample <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=http://schemas.android.com/apk/res/android android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name"> ・・・ Setting the permission information </application> for Internet Connection <uses-sdk android:minSdkVersion="3" /> <uses-permission android:name=“android.permission.INTERNET“/> // ・・・ Step1,2 </manifest> This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 77. 2.3. Android Security • In other to use the following functions, Android application set up the permission information into AndroidManifest.xml – The sample of Permission information set value Set value (android.permission) Explanation INTERNET Internet connection ACCESS_FINE_LOCATION Location information(GPS…)accession CALL_PHONE Call without using call out screen READ_CONTACTS Read in Address book WRITE_CONTACTS Write into Address book CAMERA Camera devices accession Please refer the other set value at following URL http://developer.android.com/intl/ja/reference/android/Manifest.permission.html This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 78. 2.3. Android Security • When install an application that includes use permission information, the confirmation for permitted information is executed Confirmation of Internet Connection permission This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 79. 3. Development Environment Preparation This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 80. Chapter 3: Overview • Development Tools Installation • Development Tools Installation method – Development Tool use the things stored in C:android_trainingdevtools • Emulator preparation – Android Virtual Device (AVD) creation – AVD verify operation This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 81. 3.1. Development Tools Installation • In this training, the following Development Tools will be installed Software Version Integration Development environment Eclipse 3.5 (Galileo) Java SDK JDK 1.6.0_20 Android SDK 2.1 r2 Android Plug-in Android Development Tools (ADT) Ver.0.9.X This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 82. 3.2. Development Tools Installation method • Android SDK Installation 1. Start explorer from Start Menu/[ All Program]-[Accessories]/[Explorer], open C:android_trainingdevtools 2. Right click on File android-sdk_r06-windows.zip, then choose [Open from program]-[Compresses (zip) Folders] 3. Move folder android-sdk-windows within zip into C:android_training tools 3 2 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 82
  • 83. 3.2. Development Tools Installation method • Setting Environment variables 1. 2. Open Control panel from Start Menu/ [ Control Panel], double click on [System] System/ Properties Window, on [Detail setting] Tag, click on [variable Environment] Button 1 2 This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 84. 3.2. Development Tools Installation method 3. 4. 5. 6. From a Environment variable window/[System Environment variables], select [Path], then click on [Edit] button Insert C:android_trainingtoolsandroid-sdk-windowstools; into the head of variable value in Edit window of System variable Click on [OK] button in Edit window of System variable Click on [OK] button in Environment variable window Insert 4 3 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 84
  • 85. 3.2. Development Tools Installation method 7. Check the reflect of change in environment variable 1. Click on [Command prompt] in Start Menu/[ All program]-[ Accessories] to start Command prompt 2. Execute command set<sp>|<sp>find<sp> “android” from Command prompt, check to make sure that Path setting is displayed (Refer below chart for output result) ※ <sp> ・・・ means Space This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 86. 3.2. Development Tools Installation method • Android Development Tools (ADT) Installation 1. 2. Start Eclipse On the Menu [Help] of Eclipse, select [Install New Software…] This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 86
  • 87. 3.2. Development Tools Installation method 3. If Network environment is using Proxy, make the following settings i. ii. iii. On the Menu [Window] of Eclipse, select [Preferences] On Preferences window, select [General]-[Network Connections] From Network Connections screen, select 「Manual Proxy Configuration」, setting the items below: – – HTTP Proxy: Proxy Server address (For example: 192.168.1.1) Port :Port number of Proxy Server (For example with right chart 80) ii ii i i This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 87
  • 88. 3.2. Development Tools Installation method 4. Input http://dl-ssl.google.com/android/eclipse/ into “Work with” of Available Software window, then press Enter. 4 http://dl-ssl.google.com/android/eclipse/ This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 88
  • 89. 3.2. Development Tools Installation method • Alternative method in case failed to connect to server 4-1. Click on button [Add...] of Available Software window. 4-2. Click on button [Archive] at Add Site window. 4-3. Input ADT-0.9.X.zip into “File name” as file in folder C:android_trainingdevtoolsforOffline, click on [Open] button, then click on [OK] button. 4-1 4-2 C:android_trainingdevtoolsforOffline 4-3 This material is licensed under the Creative Commons License BY-NC-SA 4.0. 89
  • 90. 3.2. Development Tools Installation method 5. 6. Check Android DDMS, Android Development Tools in Available Software window, click on [Next] button. Click on [Next] button in Install window. 5 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 6 90
  • 91. 3.2. Development Tools Installation method 7. 8. On Install window, check [I accept the terms of the license agreements], then click on [Finish] button. Installation begins Installation complete, click on [Yes] when Software Updates message displayed, restart Eclipse 9 8 This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 92. 3.2. Development Tools Installation method 9. After restarting Eclipse, check to make sure that Android Development Tools button has been inserted into Toolbar. 1 0 The Tool button of Android Development Tools is displayed This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 92
  • 93. 3.2. Development Tools Installation method • Set up Eclipse – Recognize Android SDK in ADT 1. From Menu [Window] of Eclipse, select [Preferences] 1 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 93
  • 94. 3.2. Development Tools Installation method 2. 3. 4. From Preferences window, select [Android]. After selected, Error Message will be displayed, click [OK] to close Message window. In SDK Location, input 「 C:android_trainingtoolsandroid-sdkwindows」 Check to make sure that Error message on the top of Preferences window is disappeared, then click [OK] button. 3 2 Check that Error message is disappeared C:android_trainingtoolsandroid-sdkwindows 4 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 94
  • 95. 3.2. Development Tools Installation method 5. If Network environment is using Proxy, make the following settings: i. ii. From Preferences window, select [Android]-[Launch] From the Launch screen, insert Proxy setup into [Default Emulator Options] (Format: -http-proxy<sp><Proxy Server address>:<Port number> ) – If Proxy Server address is「 http://192.168.1.1 」, Port number is「80」, make setup as follow » -http-proxy http://192.168.1.1:80 i ii This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 95
  • 96. 3.2. Development Tools Installation method 6. Select [Android SDK and AVD Manager] from menu [Window] of Eclipse. 6 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 96
  • 97. 3.2. Development Tools Installation method 7. 8. Select Available Packages from left column of Android SDK and AVD Manager window. Click on [+] of URL on right column to drop down, check on [SDK Platform Android 2.1, API-7, revision 2] then click on [Install Selected] button. ※ In offline environment, copy platform folder of C:android_trainingdevtoolsforOffline to C:android_trainingtoolsandroid-sdk-windows in responding to instruction of Trainer. 7 8 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 97
  • 98. 3.2. Development Tools Installation method 9. Select [Accept] in “Choose Packages to Install” window , then click on [Install] button. 10. After installation finished, click [Close] button to finish installation. 1 0 9 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 98
  • 99. 3.3. Emulator preparation • Create Android Virtual Device (AVD) that is device image of Emulator 1. From menu [Window] of Eclipse, select [Android SDK and AVD Manager]. 1 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 99
  • 100. 3.3. Emulator preparation 2. Click on [New] button of Android SDK Devices window. 2 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 100
  • 101. 3.3. Emulator preparation 3. When “Create new Android Virtual Device” window is displayed, set up parameters as below. Item name Set up value Name Android 2.1-update1 Skin 4. default Target 3 WVGA800 After finished setting, click on [Create AVD] button. 4 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 101
  • 102. 3.3. Emulator preparation • Start the Emulator, check that AVD has been created 1. 2. Start up “Android SDK and AVD Manager” in Eclipse, select Default for AVD Name, click on [Start] button. Check on [Scale display to real size] in “Launch Option” window, input “6” into [Screen Size (in)], then click on [Launch] button. 1 Input appropriate size according to environment. 2 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 102
  • 103. 3.3. Emulator preparation 3. Check to make sure that Emulator screen as below will be displayed. This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 103
  • 104. 4. Tutorials This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 105. Chapter 4: Overview • Learn how to operate Development Tools through creation of HelloWorld application – Android Development Tools (ADT) – Emulator, Android Virtual Device (AVD) – Dalvik Debug Monitor Services (DDMS) This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 106. 4.1. Create an application by ADT • What is Android Development Tools (ADT)? – Plug-in to develop Android applications by Eclipse. • The functions that ADT provides – Create Android projects – Execute/ debug Android applications – Support to Resource files creation • Resource files will be described in this section This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 107. p r a c t i c e 4.1.1. Display Hello World • The beginning of an Android project, create the below application – Complete image New project is creation an application that displays Hello World HelloWorld! like in the left chart This material is licensed under the Creative Commons License BY-NC-SA 4.0.
  • 108. p r a c t i c e 4.1.1. Display Hello World • Create Android project 1. 2. 3. Double click eclipse on desktop to start up Eclipse. Select [new]-[Other ] from menu [File] of Eclipse. Select [Android]-[Android Project] of New window , then click on [Next] button. 3 2 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 108
  • 109. p r a c t i c e 4.1.1. Display Hello World 4. Input following information into Project Name, Build Target, Properties from window [New Android Project]. Input HelloWorld into Project Name Check Android 2.1-update1 on Build Target Input following information into the following items of Properties Application Name :HelloWorld Package Name :jp.oesf.tutorial Create Activity :HelloWorld MinSDK Version :7 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 109
  • 110. p r a c t i c e 4.1.1. Display Hello World 5. 6. Android Project will be created, and be displayed as in left-hand picture. Select HelloWorld project from Package Explorer, right click then select [Run As]-[Android Application]. 4 5 5 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 110
  • 111. p r a c t i c e 4.1.1. Display Hello World 7. Start Emulator on other window, confirm to be sure that the following screen is displayed. • • Application title is HelloWorld. “Hello World, HelloWorld!” is displayed in application. 6 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 111
  • 112. 4.2. Create screen design • Create screen design on Resource file – What is resource file? • All external files besides source code. • Files stored below /res in Android Project. – Types of resource file (partial excluded) # Resource file Content 1 res/drawable(-Xdpi)/*.* Image file (.png, .jpeg, .gif) 2 res/layout/*.xml Screen design information (ex. main.xml) 3 res/values/colors.xml Color information 4 res/values/dimens.xml Size information (ex. 5px, 10dip, 20pt) 5 res/values/strings.xml Character string information ■Explanations related to resource file http://developer.android.com/intl/ja/guide/topics/resources/resources-i18n.html This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 112
  • 113. 4.2. Create screen design • There is function supports creating resource file in ADT. – ADT supply 3 kinds of resource file editor • Layout editor – Support creating screen design resource file. • Resource editor – Support creating resource file besides screen design resource file. • Manifest editor – Support creating AndroidManifest.xml This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 113
  • 114. p r a c t i c e 4.2. Create screen design • Use function Layout Editor, create screen that include button, check box, text input in HelloWorld. – Completed image • Use GUI function of Layout editor to add button and check box. • Edit directly screen design resource file (XML file) to add text input. • Setting as below for display character string of every View. # View Display string character 1 Button Button01 2 Check Box CB1 3 Text input EditText This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 114
  • 115. p r a c t i c e 4.2.1. Create resource file • Open screen design resource file 1. 2. Double click res/layout/main.xml from Package Explorer. When res/layout/main.xml file is opened by Layout Editor, confirm to be sure that the screen on the right-hand picture is displayed. 2 1 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 115
  • 116. p r a c t i c e 4.2.1. Create resource file • Insert button, check box into screen design by Layout tab of Layout Editor. 1. 2. 3. Select Button from [Views], drag & drop on the screen. The button will be displayed as the right-hand picture. Similarly, drag & drop CheckBox from [Views] on the screen and then confirm to be sure that it is displayed. 2 1 Drag & drop This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 116
  • 117. p r a c t i c e 4.2.1. Create resource file 4. 5. Select CheckBox01 on the screen, change Text properties from CheckBox01 to CB1 from Properties Views. Similarly, change Text properties of @+id/Button01 into Button01. Select HelloWorld project from Package Explorer, right click then select [Run As]-[Android Application]. 5 5 5 4 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 117
  • 118. p r a c t i c e 4.2.1. Create resource file 6. Start emulator, confirm to be sure that below screen is displayed . • CheckBox, Button is displayed on screen. • Confirm to make sure display character string of Button is Button01. • Confirm to make sure display character string of CheckBox is CB1. 6 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 118
  • 119. p r a c t i c e 4.2.1. Create resource file • Add text input into screen design by tab <File name> of Layout editor 1. Click on tab main.xml of Layout editor, confirm to be sure that XML source is displayed in Layout editor. ■res/layout/main.xml(partial omitted) 1 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android ・・・・・・・・・・・ > <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> <Button android:text="Button01" android:id="@+id/Button01“ ・・・・・・・・・></Button> <CheckBox android:id="@+id/CheckBox01“ android:text="CB1“ ・・・・・・・・・ ></CheckBox> </LinearLayout> This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 119
  • 120. p r a c t i c e 4.2.1. Create resource file 2. Add EditText tag that is Text Input View into main.xml. ■res/layout/main.xml(partial omitted) <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=http://schemas.android.com/apk/res/android ・・・・・・・・・・・ > <TextView ・・・・・・・・・・・ /> <Button ・・・・・・・・・></Button> <CheckBox ・・・・・・・・・ ></CheckBox> <EditText android:id="@+id/EditText01" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="EditText"></EditText> </LinearLayout> 2 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 120
  • 121. p r a c t i c e 4.2.1. Create resource file 3. Switch display in Layout Tab, confirm to be sure that EditText is displayed as below. Switch display EditText is displayed in Layout Tab 3 EditText added This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 121
  • 122. p r a c t i c e 4.2.1. Create resource file 4. Select HelloWorld project from Package Explorer, right click then select [Run As]-[Android Application]. When Emulator starts, confirm to be sure that the right-hand screen is displayed. 5. • • 4 Text input is displayed. Display character string of Text input is EditText. 5 5 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 122
  • 123. 4.2.1. Create resource file • Attention points when using Layout Editor 1. Although we tried to paste View group in Layout tab (View included in Layout) to the screen by drop & drag, ViewGroup was not be displayed on the screen. • 2. Handle the following matter by edit directly XML. – Arrange View of buttons, etc. within ViewGroup. Unable to select CustomView from [Views] • Handle by edit directly XML. 1 Although we arranged LinearLayout but it is not disaplayed This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 123
  • 124. 4.2.1. Create resource file • Mechanism of screen create usage resource file – Activity uses Class R to acquire content of screen design resource file. • Class R – Class generated automatically at the time of “build”. – The class necessary to acquire information of resource file from program. – Display screen design from resource file information acquired by Activity#setContentView. ■HelloWorld.java R.layout.main will display main.xml public class HelloWorld extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } } ■setContentView Display screen design on Activity <?xml version="1.0" encoding="utf-8"?> <LinearLayout ・・・・・・・・・・・ > ・・・・・・・・・・・ <EditText android:id="@+id//EditText01“ ・・・・・・・・・・・ android:text="EditText"></EditText> </LinearLayout> This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 124
  • 125. 4.2.1. Create resource file • Relationship between R class and resource file – Program and resource information will be connected by resource ID. ■HelloWorld.java setContentView(R.layout.main); Reference ■R.java public static final class layout { public static final int main=0x7f030000; } Resource ID This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved Resource file 125
  • 126. p r a c t i c e 4.3. Use resource besides design • Change display character string “Button01” of button that was added into HelloWorld to “Hello Button”. • Set display character string into character string resource file. – Completed image This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 126
  • 127. 4.3. Use resource besides design • Character string resource file is resource file defined character string using in application. (res/values/strings.xml) ■Character string resource file (res/values/strings.xml) <?xml version="1.0" encoding="utf-8"?> <resources> <string name="hello">Hello World, HelloWorld!</string> <string name="app_name">HelloWorld</string> </resources> Refer to character string ■TextView 1. Add character string that displays on the screen into character string resource file. on screen design resource file (res/layout/main.xml) <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/hello" /> Execute 3. Character string set in strings.xml is displayed. 2. Refer to character string of character string resource file from Text Properties in TextView This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 127
  • 128. p r a c t i c e 4.3. Use resource besides design • Insert character string set-up into character string resource file. 1. 2. Double click on res/values/strings.xml from Package Explorer. Open file res/values/strings.xml by Resource Editor, then confirm to be sure that the right-hand screen is displayed. 2 1 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 128
  • 129. p r a c t i c e 4.3. Use resource besides design 3. 4. Click on [Add…] button of Resource Tab, display Option screen of additional element. Select String from Option screen, click [OK] button. 3 4 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 129
  • 130. p r a c t i c e 4.3. Use resource besides design 5. 6. Confirm to be sure that String was inserted into Resources Elements of Resources Tab. Input value into Name, Value of “Attributes for String” of Resources Tab as below. Setting value of “Attributes for String” Item Name 5 Name button_label Value 6 Setting value Hello Button This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 130
  • 131. p r a c t i c e 4.3. Use resource besides design 7. 8. 9. Double click on res/layout/main.xml from Package Explorer After starting up Layout editor, open Layout Tab, then select Button01 Change Text properties into @string/button_label from Properties View. 8 7 9 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 131
  • 132. p r a c t i c e 4.3. Use resource besides design 10. Select HelloWorld project from Package Explorer, right click then select [Run As]-[Android Application]. 11. Start emulator, confirm to be sure that the right-hand screen is displayed. • Display character string of Button will become Hello Button. 11 10 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 132
  • 133. 4.4. Modify Manifest file • Manifest editor – There are 5 functions to modify Manifest file. • Manifest Tab – Version information, extension information, etc… • Application Tab – usage component information, icon, application name, etc… • Permissions Tab – Access limit setting • Instrumentation Tab – Setting Class used for information gathering of profile, etc… (ex: TestRunner, etc…) • AndroidManifest.xml Tab – Edit directly XML file This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 133
  • 134. 4.4. Modify Manifest file • What is manifest file? – AndroidManifest.xml (1 file exists in application) – Define the following information related to application. • • • • • Setting icon, title of application. Definition about usage component (Activity, Service, etc…) Definition related to conduct of component. Setting access limit of application. Setting usage of library. ■Explanation related to Manifest file. http://developer.android.com/intl/ja/guide/topics/manifest/manifest-intro.html This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 134
  • 135. 4.4.1. Add Activities into application • Add Activities into application File name Additional Activities HelloWorld2.java Additional screen design resource file res/layout/ helloworld2.xml – Add Activities HelloWorld2 into application. – The screen design resource file of HelloWorld2 is helloworld2.xml. This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 135
  • 136. 4.4.1. Add Activities into application • Setting by Application Tab so that it is possible to use Activities added to application. 1. 2. Double click on AndroidManifest.xml from Package Explorer Open file AndroidManifest.xml by Manifest editor. Select Application Tab in Manifest editor, then confirm to be sure that the right-hand screen is displayed. 2 1 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 136
  • 137. 4.4.1. Add Activities into application 3. 4. Click on [Add…] button in Application Nodes, display Option screen of additional element. Select Activity from Option screen, then click [OK] button. 4 3 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 137
  • 138. 4.4.1. Add Activities into application 5. 6. Confirm to be sure that Activity has been added into Application Nodes. Input value as below into Name of Attributes for Activity. Item name Name 5 Setting value HelloWorld2 6 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 138
  • 139. 4.4.2. Set up Right of access to internet • Set up Right of access to internet by Permissions Tab 1. 2. Double click on AndroidManifest.xml from Package Explorer. Open AndroidManifest.xml file by Manifest editor. Select Permissons Tab in Manifest editor, confirm to be sure that the screen on the right-hand picture is displayed. 2 1 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 139
  • 140. 4.4.2. Set up Right of access to internet 3. 4. Click on [Add…] button in Permissions, display Option screen of additional elements. Select Uses Permisson from Option screen, then click on [OK] button. 3 4 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 140
  • 141. 4.4.2. Set up Right of access to internet 5. 6. 5 Confirm to be sure that Permission is added into Permissions. Select android.permission.INTERNET from pull-down menu of Name in Attributes for Uses Permission. 6 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 141
  • 142. 4.5. Usage method of emulator • What is emulator? – Read Android Virtual Device (AVD), emulate hardware operation on computer. • Function / Setting that not be supported by emulator – – – – – – – Actual incoming call, outgoing call USB connection Camera/Videographer Headphone connection Communication usage Bluetooth Connection status setting Battery charging level, AC power source setting This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 142
  • 143. 4.5. Usage method of emulator • What is Android Virtual Device (AVD)? – It contains Android terminal information. • Android operating environment information (Operating environment for every version of Android) • Skin information (outside exterior, monitor size) • SD Card information This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 143
  • 144. 4.5. Usage method of emulator • Operating method of emulator # Device key Content 1 Volume UP 1 2 3 2 Volume DOWN 11 4 3 Power source Power On/Off 10 5 4 Select button Select button 5 End call 9 8 7 6 Home Move to Search window 7 Return Return to previous screen 8 Menu 12 6 Search Display menu on the screen 9 Home Display home 10 Start call 8 11 Cross key Move cursor 12 Keyboard Key input This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 144
  • 145. 4.5. Usage method of emulator • Switching screen orientation (Ctrl + F11) – Screen display that fits orientation of device. Portrait display Landscape display Detail information related to Android emulator http://developer.android.com/intl/ja/guide/developing/tools/emulator.html This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 145
  • 146. 4.6. Usage method of debug tool • ADT – We can use debug function of Eclipse in Android application development. • Breakpoint • Step execution • Dalvik Debug Monitor Services (DDMS) – Android SDK Debug tool pack – There are functions as below: • Monitoring • Emulator operating • Acquiring information in emulator/hardware This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 146
  • 147. 4.6.1. Usage method of ADT • Usage method of Breakpoint/Step execution – Both of setting method of Breakpoint/Step execution are similar to usage method of Eclipse. Debug View and Step execution Interrupt processing by Breakpoint This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 147
  • 148. 4.6.1. Usage method of ADT • Attention points when debugging on ADT – It is necessary to set up in AndroidManifest.xml to debug using hardware (Real Android terminal). ■AndroidManifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="jp.oesf.mtgeduwg.training.rssreader" android:versionCode="1" android:versionName="1.0"> <application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="true"> ・・・ </application> Set up debug <uses-sdk android:minSdkVersion=“7" /> </manifest> This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 148
  • 149. 4.6.2. Usage method of DDMS • 2 methods to start DDMS – Execute ddms command 1. 2. Select [Command prompt] in [All programs]-[Accessories] on Start Menu, then start Command prompt. Input ddms in Command prompt, then press [Enter] key. DDMS started from command This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 149
  • 150. 4.6.2. Usage method of DDMS • 2 methods to start DDMS – Use DDMS from Eclipse 1. Select [Open Perspective]-[Other…]-[DDMS] from menu [Window] of Eclipse. ※There is some functions that are unavailable compared to DDMS that started command. DDMS perspective of Eclipse This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 150
  • 151. 4.6.2. Usage method of DDMS • Debug function of DDMS – Monitoring 1. 2. – Transmitting data to emulator 1. 2. 3. – – Outgoing call SMS sending Transmit position information Acquiring screenshot Process management 1. 2. – Refer to log that application output Refer to usage status resource Execute garbage collection Interrupt process File operation This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 151
  • 152. 4.6.3. Application log reference • Application log reference – We can refer to log that application outputs from LogCat view. LogCat Display log information that be output from application. Log Level Level E Error information W Warning information I Operation information D Debug information V Detail information This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 152
  • 153. 4.6.3. Application log reference • Application log reference – Use log output method of android.util.Log class to output log. ■ Sample code import android.util.Log; Log.e(“HelloWorld”, “Error Message”); // Log that outputs errors Log.w(“HelloWorld”, “Warning Message”); // Log that outputs warnings Log.i(“HelloWorld”, “Infomation Message”); // Log that outputs information of application operation Log.d(“HelloWorld”, “Debug Message”); // Log that outputs debug information Log.v(“HelloWorld”, “Verbose Message”); // Log that outputs detail information Output Log This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 153
  • 154. p r a c t i c e 4.6.4. Output log from Hello World • Output application log when starting HelloWorld 1. 2. Double click on HelloWorld.java from Package Explorer. Confirm to make sure that source code of HelloWorld.java is opened, screen on the right-hand picture is displayed. 2 1 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 154
  • 155. p r a c t i c e 4.6.4. Output log from Hello World 3. Add 5 code that execute log output into HelloWorld#onCreate. ■HelloWorld.java package jp.oesf.tutorial; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class HelloWorld extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); Log.e("HelloWorld", "Error Message"); Log.w("HelloWorld", "Warning Message"); Log.i("HelloWorld", "Infomation Message"); Log.d("HelloWorld", "Debug Message"); Log.v("HelloWorld", "Verbose Message"); 6 } } This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 155
  • 156. p r a c t i c e 4.6.4. Output log from Hello World 4. 5. Select HelloWorld project from Package Explorer, right click then select [Run As]-[Android Application]. Confirm to be sure that emulator runs & right-hand screen is displayed. 5 4 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 156
  • 157. p r a c t i c e 4.6.4. Output log from Hello World 6. 7. Modify perspective of Eclipse into DDMS, confirm to be sure that screen of DDMS is displayed. Confirm to be sure that 5 logs are output in LogCat view. 6 7 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 157
  • 158. 4.6.5. Confirm resource usage status • Refer to resource usage status – Information available to refer and display screen • Info view (Only when executing command) – Display process information (ID, DalvikVM information) • Threads View – Display information of operating threads. • VM Heap View – Display usage status of Heap memory. • Allocation Tracker View – Display memory ensure status (ensure class, method, etc…). • Sysinfo View (only when executing command) – Display in graph format system status (CPU usage rate, memory status). This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 158
  • 159. 4.6.5. Confirm resource usage status • Refer to VM Heap information Set Update into process that you want to display Heap information. Display in list the following items: Type of objects Number of objects Total amount of usage memory Minimum usage memory Maximum usage memory Average usage memory This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 159
  • 160. p r a c t i c e 4.6.6. Transmit call to emulator • Transmit call (Transmit call to emulator) 1. 2. 3. Select Emulator Control View. Input phone number (09010000001) into Incoming number. Select Voice, then click [Call] button. Emulator Control Input incoming number ex. Incoming number : 09010000001 Select Voice Call : Transmit call Hang Up : Hang up the phone 1 Transmit call to Emulator, send SMS, position information. 2 3 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 160
  • 161. p r a c t i c e 4.6.6. Transmit call to emulator 4. Confirm incoming call from 09010000001 to emulator. 4 Incoming call to emulator from 09010000001 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 161
  • 162. 4.6.7. Send SMS to emulator • SMS sending (Send SMS to emulator) 1. 2. 3. Select Emulator Control View. Input phone number (09010000001) into Incoming number. Select SMS, input sending message (Hello Android) into Message, then click [Send] button. Input incoming number ・message ex. Incoming number : 09010000001 Select SMS Message : Hello Android 2 3 Send : Sending This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 162
  • 163. 4.6.7. Transmit SMS to emulator 4. Confirm to be sure that message was transmitted from 09010000001 to emulator. Notify “SMS receiving” Message that sent into Messaging application, will be recorded. 4 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 163
  • 164. 4.6.8. Send position information to emulator • Send position information 1. 2. 3. 4. Select Emulator Control view. Open Manual tab, select Decimal. Input Longitude/Latitude. Click on [Send] button. This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 164
  • 165. 4.6.9. Other functions of emulator • Acquire screenshots 1. 2. When you click on [Screen Capture] button, screenshots of terminal will be displayed on Device Screen Capture window. Click [Save] button, then save file from Save window. 1 2 Preview display will be displayed on Device Screen Capture. There are some function including Save as below: Refresh : Re-acquire Save : Save Done : Finish This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 165
  • 166. 4.6.9. Other functions of emulator • Execute garbage collection 1. 2. Select process that executed garbage collection from Devices View. Click on [Cause GC] button in Heap View 2 1 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 166
  • 167. 4.6.9. Other functions of emulator • Stop process 1. 2. Select process that executed garbage collection from Devices View. Click on [Stop Process] button in Devices View. 2 1 This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 167
  • 168. 4.6.9. Other functions of emulator • Acquire/Forward/Delete file within Terminal device 1. 2. Select FileExplorer View. Click on buttons correspond to operation (Acquire/Forward/Delete file) 1 File Explorer Display file information within terminal device. Reference scope is limited because there is limit access for real device. 2 : Retrieve file from terminal : Forward file to terminal : Delete file This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 168
  • 169. 5. Practice This material is licensed under the Creative Copyright 2009, Open Embedded Software Foundation, All rights reserved Commons License BY-NC-SA 4.0. 169
  • 170. 5.1. Outline How to practice? • Learn how to develop Android application in 5 steps Step 2: The method to make screen transition Step 1: The method to make screen design - Make menu screen - Recognize “Button has been clicked“ - Add screen in List format - Use intent to make screen transition Step 4: Search database with specific criteria & display data in detail screen - Receive and send parameters between activities - Make narrow search from database - Set screen view properties from the program Step 3: SQLite database operations & display data in list format - Create database and table - Search data from database - Display searching result in list format Step 5: How to create option menu - Add option menu to application - Recognize “option menu clicked” - Display dialogue on screen This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 170
  • 171. 5.1. Outline Preparation for practice • Take skeleton project for practice in Eclipse. – Storage place • C:android_trainingskeleton_project – Take 「RssReaderSkeleton1」in this folder. – How to take it in? • Start Eclipse, select 「Import」 from 「File」menu, display 「Import」 dialog. • Select 「Existing Projects into Workspace」 from 「General」 in 「Import」 dialogue, and press 「Next」 button, specify then take root directory in skeleton project in. – Make a check mark in 「Copy projects into workspace」. This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 171
  • 172. 5.1. Outline Practice application outline • Create RSS Reader in practice – RSS reader created in practice will acquire RSS feed ( information in XML format) from internet and be saved in database. Search database, then display RSS feed on screen. Get RSS feed from internet Menu screen Register RSS feed into database. Internet Database Search RSS feed from database After registration into database finished, display dialogue. List screen Click “List display” button Select List data This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved Detail screen 172
  • 173. 5.1. Outline Practice application outline • RSS reader screen and function outline – RSS reader created in practice, is configured by 3 screens. RSS reader Start ① Menu screen ・・・ Direction of screen transition ② List screen ③ Detail screen # Screen name Function outline 1 Menu screen • Start List screen • Display option menu • After clicking on option menu, get RSS feed from internet then register into database • After getting RSS feed, display Finish message on dialogue. 2 List screen • Display RSS feed that is registered in database in List format. 3 Detail screen • Display title, sending time, sender’s name, detail content of RSS feed that is selected in List screen. This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 173
  • 174. 5.2. The method of making screen design • Learn how to make screen design in Android application. • Learn the following via practice. – Method of making screen design using Layout editor. – Method of creating string character resource file using Resource editor. This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 174
  • 175. 5.2. The method of making screen design Create menu screen • Method of making screen design using Layout editor. – We can make screen design based on resource file in XML format in Android application. 1. Resource file Open (res/layout/main.xml), start layout editor 2 (Refer to「4.2.1. Create resource file」for Layout editor) 2. Display in Menu screen Arrange 「List display」button by Drag & Drop 1 Arrange 「Button」 from 「Views」 by Drag & Drop (Refer to「4.2.1. Create resource file」for method of arranging button) Use Layout editor to open res/layout/main.xml This material is licensedEmbedded Creative Commons License BY-NC-SA 4.0. Copyright 2009, Open under the Software Foundation, All rights reserved 175
  • 176. 5.2. The method of making screen design Create menu screen 3. Use Properties View, set properties of arranged button. – Set id, layout_width, layout_height 3 3. Set id, height, width in properties. This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 176
  • 177. 5.2. The method of making screen design Create menu screen • Setting value of properties – id • id that use when refers to View from program. • Format of setting value – @+id/<option id> • Set example (In case of putting id that called ”a_button” on button) – @+id/a_button – layout_width • Set the width of View • Format setting value – Numerical value +Unit ・・・ Specify by numerical value. Specify px, dip, etc … as for unit. – wrap_content ・・・ Fit the width of display character string, etc … in View. – fill_parent ・・・ Fit automatically numerical value in new View. – layout_height • Set height of View • Format of setting value is similar to layout_width This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 177
  • 178. 5.2. The method of making screen design Create menu screen • Confirm to be sure that the screen created in emulator will be displayed. – Select project in Android application, right-click then select 「Android Application」 from 「Run As」. Specify 「RssReader」project, and right-click Implement application Select 「Android Application」 from 「Run As」 in menu that is displayed when right –click This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 178
  • 179. 5.2. The method of making screen design Create menu screen • Use resource editor, set character string displayed on screen into character string resource file (res/values/strings.xml). – We can collect character string that displayed on the screen into resource file in Android application. ■Character string resource file (res/values/strings.xml) Add character string that display on the screen into character string resource file. <?xml version="1.0" encoding=“utf-8"?> <resources> <string name=“app_name”> RssReader </string> <string name=“go_to_list_page_button_label”> List Display</string> </resources> Refer to character string ■Resource file of screen design (res/layout/main.xml) Refer to character string of character <Button string resource file from button android:id="@+id/list_button" properties. android:layout_width="wrap_content" android:layout_height="wrap_content" android:text=“@string/go_to_list_page_button_label“ /> This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 179
  • 180. 5.2. The method of making screen design Create menu screen • Refer to character string that display in button be disposed in menu screen from character string resource file. – Use resource editor, open character string resource file (res/values/strings.xml). – Add setting of button display character string into character string resource file. (Refer “4.3. Use resource besides design” for additional procedure) – Use Layout Editor, open Screen design resource file (res/layout/main.xml), use character string of character string resource file by character string of button properties. – Execute application, confirm to be sure that character string is displayed. This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 180
  • 181. p 実 5.2. The method of making screen r 習 Create menu screen a c t Practice 1 i c • Practice theme – Create screen design of Menu screen. e design • There is 1 button in Menu screen. • Display “List Display” in the button. This material is licensed under the Creative Copyright 2009, Open Embedded Software Foundation, All rights reserved Commons License BY-NC-SA 4.0. 181
  • 182. p 実 5.2. The method of making screen design r 習 Create menu screen a c t Practice 1 i c • Practice procedure 1. Open resource file (res/layout/main.xml) by Layout Editor, arrange e buttons in Menu screen. 2. Set properties (id, height, width) for arranged buttons. 3. Add “List Display” to character string displayed in button into character string resource file (res/values/strings.xml). 4. Change setting of character string resource file that Text properties of the button is set into “Reference”. This material is licensed under the Creative Copyright 2009, Open Embedded Software Foundation, All rights reserved Commons License BY-NC-SA 4.0. 182
  • 183. p 実 5.2. The method of making screen design r 習 Create menu screen a c t Practice 1 i – Setting information 1 c • Set the following value for View properties arranged in the screen. e # 2 View Properties 1 1 LinearLayout 1. android:layout_width=“fill_parent” 2. android:layout_height=“fill_parent” 2 Button 1. 2. 3. 4. android:id=“@+id/list_button” android:layout_width=“fill_parent” android:layout_height=“wrap_content” android:text=“@string/go_to_list_page_button_label” This material is licensed under the Creative Copyright 2009, Open Embedded Software Foundation, All rights reserved Commons License BY-NC-SA 4.0. 183
  • 184. p 実 5.2. The method of making screen design r 習 Create menu screen a c t Practice 1 i – Setting information 2 c • Add the following value character string into character string resource file. e ※ The format added into character string resource file will be <string name=“Key”>Value</string> Key Value Content go_to_list_page_button_label List display Character string displayed in button 「List display」 This material is licensed under the Creative Copyright 2009, Open Embedded Software Foundation, All rights reserved Commons License BY-NC-SA 4.0. 184
  • 185. p 実 5.2. The method of making r 習 Create menu screen a c t Practice 1 i – Setting information 3 c • Create the following resource file. e Screen Menu screen - Resource file screen design Description res/layout/main.xml (Resource file) • Arrange button “List display” in Menu screen res/values/strings.xml (Character string resource file) • Add character string “List display” displayed in the button “List display”. This material is licensed under the Creative Copyright 2009, Open Embedded Software Foundation, All rights reserved Commons License BY-NC-SA 4.0. 185
  • 186. p 実 5.2. The method of making screen design r 習 Create menu screen a c t Practice 1 i c • Verification method – Execute the practice application, make sure that “List display button” is e displayed. This material is licensed under the Creative Copyright 2009, Open Embedded Software Foundation, All rights reserved Commons License BY-NC-SA 4.0. 186
  • 187. p 実 5.2. The method of r 習 Create menu screen a c t Practice 1 i c • Practice answer – res/layout/main.xml e making screen design <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent“ > <Button android:id="@+id/list_button" android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="@string/go_to_list_page_button_label" /> </LinearLayout> This material is licensed under the Creative Copyright 2009, Open Embedded Software Foundation, All rights reserved Commons License BY-NC-SA 4.0. 187
  • 188. p 実 5.2. The method of r 習 Create menu screen a c t Practice 1 i c • Practice answer – res/values/strings.xml e making screen design <?xml version="1.0" encoding="utf-8"?> <resources> <string name="app_name">RssReader</string> <string name="go_to_list_page_button_label"> List display </string> </resources> This material is licensed under the Creative Copyright 2009, Open Embedded Software Foundation, All rights reserved Commons License BY-NC-SA 4.0. 188
  • 189. 5.3. The method of screen transition • Learn how to make screen transition in Android application • Learn the following by practice – The method of recognizing that “Button has been clicked”. – The method of adding the screen in list format to application. – The method of implementing screen transition used Intent class. This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 189
  • 190. 5.2. The method of making screen transition Recognize “Button has been clicked” • How to recognize “Button has been clicked” – Mechanism • When you click a button, “Event” will be created. Prepare “Event listener” to recognize this event by program. • Register “Event listener” that has been created beforehand to the button that you want to recognize event. • When event created by button, specified method will be retrieved. Event listener public void onClick(View view) { Click button // Process Event raised } Processing will be executed This material is licensedEmbedded SoftwareCommons License BY-NC-SA 4.0. Copyright 2009, Open under the Creative Foundation, All rights reserved 190