Android Application Development

gatecircleΚινητά – Ασύρματες Τεχνολογίες

10 Δεκ 2013 (πριν από 3 χρόνια και 10 μήνες)

282 εμφανίσεις

1

Android Application Development

Lecture I: Startup

2

Purpose

1)
--

EDE project

2)
--

EDE project

3)

--

EDE project


4)
Technical

abilities:


Objective C
を用いたオブジェクト指向プログラミング

(Object Oriented
Programming by Objective C)


iOS
プログラミング入門

(Getting started with
iOS

programming
)


エディタ、コンパイラ、デバッガなどが融合された統合開発環境
-
xcode

よる実践

(Experience in coding and debugging the source code in an
Integrated Development Environment


xcode
)

3

Purpose


自律性
(A
-
1, A
-
2)

グループの目標
を揚げ、その目標に向かい計画的かつ継続的に行

する



協調性
(B
-
3)

チームの共通目標に向かい、全体の進捗に合わせ、常に他のメンバーと
コミュニケーションとりながら作業を進める



コミュニケーション能力

(C
-
2)

モデルの設計や共同開発を通し,自分
の意見を
メンバー
に適切
に伝え、他の
メンバーの意見もしっかりと聞く



問題解決能力

(G
-
1, G
-
2)

問題を分析し、モデル化を行い、
課題を
適切に設定
する。ま
た、与えられた
制約
条件の下での解決方法を複数検討し、相互評価を行い、最終的に
1つの解決方法を実装する。



実践性
(F
-
1

F
-
2)
課題を行うことで、モデリング能力・プログラミング能力・設計から検証
までに関する実践的な能力を身に
つける


Android
プログラミング入門


モデリングからコーディング、そして検証までの実践

Requirements:



Java

OOP
プログラミングの基本知識

(Basic knowledge of Java and OOP
programming)



ハードウェア

(OS: Mac OS X 10.5.8, Windows XP or later, RAM >= 2GB)



ソフトウェア

(Eclipse with Android Development Tools (ADT) plug
-
in)

Communications and Materials:



Book
: (1) Google Android
プログラミング入門




(2)
入門

Android 2
プログラミング



The online
Dev

Guide
http://developer.android.com/guide/



Recommended web site:


逆引き
Android
入門


http://www.adakoda.com/android/


日本
Android



http://www.android
-
group.jp
/


ソフトウェア
設計のためのモデルの
開発


http://msdn.microsoft.com/ja
-
jp/library/dd409436.
aspx










4

Information

5

Contents
-

Lectures

I.
Startup

I
-

1. What is Android?

I
-

2.
Download and install


IV
.
Provider/service/location/map

I
-

3.
The first android application

III
.
UI and
data control

II
. Application Fundamentals

I
-

4. Other attempts


6

Contents
-

Lecture I

I
-

1. What is Android?

I
-

1.1. Android icon

I
-

1.2. Market share

I
-

4. Other attempts

I
-

1.3. Android architecture

I
-

3. The first android application

I
-

2
. Download and install

7

I
-

1.1. Android
とは

Google
が開発した、携帯端末用のオープソースのプラットフォーム

Nexus one

Galaxy tab

htc

Design HD

IS03

8

I
-

1.2. Android: market share

http://
en.wikipedia.org
/wiki/Smartphone

9

I
-

1.2. Android: market share

http://
en.wikipedia.org
/wiki/Smartphone

http://
www.gartner.com
/it/
page.jsp?id
=1466313

10

I
-

1.3
. Android Architecture

11

I
-

1.3. Android
Architecture


Linux kernel


Android is
based on Linux kernel, but is not a Linux


The Linux kernel provides Display Driver, Camera Driver, Flash
Memory Driver, Binder (IPC) Driver, Keypad Driver,
Wifi

Driver,
Audio Drivers, Power Management.


It doesn’t include all of the Linux kernel

12

I
-

1.3. Android Architecture


Libraries


Bionic
libc


Media framework (support standard audio and video)


Web kit: open source, support CSS,
Javascript
, DOM, Ajax


SQLite
: embedded relational database


2D/3D graphic libraries

13

I
-

1.3. Android Architecture


Android Runtime


Development language: Java


Dalvik Virtual Machine (DVM)


Instructions: Dalvik executable (
dex

format)


Different from Java Virtual Machine (JVM)


JVM instructions: Java
bytecode

(.class)

14

I
-

1.3. Android Architecture


DVM

http://
itpro.nikkeibp.co.jp
/article/COLUMN/20091208/341738/

15

I
-

1.3. Android Architecture


DVM


Java VM
に似た仮想マシン、
ARM
プロセッサ向けに最適化



Java
のクラスファイルから変換した
DEX
フォーマットのバイナリ
コードで実行



JVM
は“スタック・ベース


、データをスタックに格納
して演算処
理を実行する
。レジスタ・ベースの
DVM

CPU
内部のレジスタに
データを格納して演算処理を
実行し、
より高速に動作する




JNI (Java Native Interface)
をサポートして
いるため、
C

C++


コードで連携可能



Android 2.2

JIT
コンパイラ搭載、従来より
2
-
5
倍の処理速度

16

I
-

1.3. Android
Architecture

-

the compile and binary code

17

I
-

1.3. Android
Architecture

-

the compile and binary code

18

I
-

1.3. Android Architecture


Android Runtime


Activity Manager


Content Provider


Resource Manager


Notification Manager


View System


Location Manager


GPS, car navigation, map…

19

I
-

1.3. Android Architecture


Applications


Development language: Java

20

Contents

I
-

4
. Other attempts

I
-

3
. The first android application

I
-

2. Download and install

I
-

1
. What is Android?

I
-

2.1
. Preparation

I
-

2.2
. Install Android SDK and ADT

I
-

2.3
. Add Android platforms

I
-

2.4
. Exploring SDK directory

Step 1
. Preparing your development computer


Open
http://developer.android.com/sdk/installing.html


(a) Check your System Requirements



--
> confirm the version by the following commands:


$java
-
version


java version "1.6.0_20”


$ which
javac


/
usr/bin/javac


$
ls

-
al /System/Library/Frameworks/
JavaVM.framework
/Versions


lrwxr
-
xr
-
x

1 root wheel 3 May 20 15:21
CurrentJDK

-
> 1.6



(
b
) Eclipse Classic 3.5.2 (162 MB), The classic Eclipse download: the Eclipse

Platform,
Java Development Tools
, and Plug
-
in Development Environment



http://www.eclipse.org/downloads/

21

I
-

2.1. Preparation

Step 2
. Downloading the SDK Starter Package



Download the Android SDK.



Move it to $HOME/Library/



edit your
~/.
bash_profile

and set the PATH environment variable


export PATH=$PATH:$HOME/Library/android
-
sdk
-
mac_86/tools



test:


$android



Step 3
. Installing the ADT
Plugin

for Eclipse


Android Development Tools
plugin

(optional)


https://dl
-
ssl.google.com
/android/eclipse/


22

I
-

2.2
. Install SDK and ADT

Step 4
. Adding Android Platforms and Other Components


$android


or open Eclipse or Select
Window
>
Android SDK and AVD Manager
.

23

I
-

2.3
. Install Android platforms and other components

Step 5
. Exploring the SDK. Please explore the SDK directory.

24

I
-

2.4. Exploring SDK directory

25

Contents

I
-

3.1
. Create an AVD

I
-

3.2
. Create new Android project

I
-

4
. Other attempts

I
-

3.3
. Project files (1)

I
-

3
. Build your first android application

I
-

2. Download and install

I
-

3.4
. Run the app

I
-

3.5
. Entry of the app

I
-

3.7
. Resource file

I
-

3.6
. Project files (2)

I
-

1
. What is Android?

26

I
-

3.1. The first android app


Create an AVD

http://developer.android.com/resources/tutorials/hello
-
world.html


Step 1.

Skip the step of “Install a Platform”

Step 2.

Create an AVD

1)
In Eclipse, choose
Window
>
Android SDK and AVD Manager
.

2)
Select
Virtual Devices
in the left panel and click
New
, The Create New AVD
dialog appears.

3)
Type the name of the AVD, such as ”
gavd
".

4)
Choose a target. The target is the platform (that is, the version of the Android
SDK, such as 2.2) you want to run on the emulator.

5)
You can ignore the rest of the fields for now.

6)
Click
Create AVD
.


27

I
-

3.1
.
The first android app


Create an AVD

28

I
-

3.2
.
The first android app


New android project

Step 3.
Create a new android project

1)
From Eclipse, select
File
>
New
>
Project
, select “Android project” and click
Next


29

I
-

3.2. The first android app


New android project

2)
Input the project
details


Project name:


HelloOkinawa
-
proj

Application name:


Hello, Okinawa

Package name:


com.ede.hellookinawa

Create Activity:


HelloOkinawa_Activity

Min SDK Version:


nothing

30

I
-

3.3. The first android app


Project files (1)

Step 4.
Browse the created files in your project

31

I
-

3.4
.
The first android app



Run the app

Step 5.
Run the application


Select
Run > Run > "Android Application".


Notice:

The Android emulator might take
several minutes to boot

32

I
-

3.5
. What is the entry of the application?

Entry:
HelloOkinawa_activity.java
, please change the code as the following, and run the
application again.

Hit:
Command + Shift + O
: import the system package automatically

33

I
-

3.6
. Project files (2)
-

contents or responsibilities

Project name: same as the root folder name of the project

The entry of the application is here

Auto
-
compiled resources IDs, don’t change this

Application icon, you can change it as your own icon file

The layout of the main window

String variables

Application configuration

Some properties

34

I
-

3.7
. Resource file


Strings and R (XML format)

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

<resources>


<string name=
"
hello
">
My first android application, Hello Okinawa!
</string>


<string name=
"
app_name
">
Hello, Okinawa
</string>

</resources>

Strings.xml

package

com.example.hellookinawa
;


public

final

class

R {


public

static

final

class

attr

{


}




public

static

final

class

string
{


public

static

final

int

app_name
=0x7f040001;


public

static

final

int

hello
=0x7f040000;


}

}

R.java

35

I
-

3.7
. Resource file
-

The main window:
main.xml

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

<
TextView

xmlns:android
=
"http://
schemas.android.com/apk/res/android
"


android:id
=
"
@+id/
textview
"


android:background
=
"#
ffffff
"


android:layout_width
=
"
fill_parent
"


android:layout_height
=
"
fill_parent
"


android:text
=
"
@string/hello
"/>

main.xml




public

static

final

class

id {


public

static

final

int

textview
=0x7f050000;


}


public

static

final

class

layout {


public

static

final

int

main
=0x7f030000;


}

R.java

Point to
main.xml

Point to
hello
in
strings.xml

36

I
-

3.7. Resource file
-

in Java source

public

class

HelloOkinawa_activity

extends

Activity
{

@Override


public

void

onCreate(Bundle

savedInstanceState
) {


super.onCreate(savedInstanceState
);


setContentView(
R.layout.
main
);


}

}

HelloOkinawa_activity.java




public

static

final

class

id {


public

static

final

int

textview
=0x7f050000;


}


public

static

final

class

layout
{


public

static

final

int

main
=0x7f030000;


}

R.java

Point to
main.xml

37

3.7. Resource file
-

Configurations
of your application

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

<manifest
xmlns:android
=
"http://
schemas.android.com/apk/res/android
"


package=
"
com.example.hellookinawa
"


android:versionCode
=
"1"


android:versionName
=
"1.0">


<application
android:icon
=
"@
drawable
/icon"
android:label
="@string/
app_name
"
android:debuggable
="true"
>


<activity
android:name
=
".
HelloOkinawa_activity
"


android:label
=
"@string/
app_name
"
>


<
intent
-
filter
>


<action
android:name
=
"
android.intent.action.MAIN
" />


<category
android:name
=
"
android.intent.category.LAUNCHER
" />


</intent
-
filter
>


</activity>



</application>


<uses
-
sdk

android:minSdkVersion
=
"8" />

</manifest>


AndroidManifest.xml

If you have many activities classes,

define them here.

Specify the entry activity by <
intent
-
filter
>

Set
debuggable

to
true

38

Contents

I
-

4.1
. Debug /
adb

/
ddms

I
-

4.3
. Connect to android device by IP

I
-

4
. Other attempts

I
-

4.4
. Project files in the release version

I
-

2. Download and install

I
-

4.5
. Files in the release version
-

.
apk

I
-

1
. What is Android?

I
-

4.6
. Locale and text

I
-

4.2
. Log in
ddms

I
-

3. Build your first android application

39

I
-

4.1
. Debug /
adb

/
ddms

Debug your application

Add some code the
OnCreate

method of class
HelloOkinawa_activity
,

set the breakpoint and debug it

Command line tools:
adb

[
mbp:~/Downloads/apks
]$
adb

devices

List of devices attached

[
mbp
:~/Downloads/
apks
]$
adb

-
s emulator
-
5554 install “
hello.apk


[
mbp
:~/Downloads/
apks
]$
adb

-
s emulator
-
5554 uninstall “
hello.apk



[
mbp:~/Downloads/apks
]$
adb

shell

#
ls


l

>>>>>>>>>>>>>>>> check the files of android emulator or devices.



Open the perspective
ddms

from eclipse


Browse the folders and files in the emulator.


Copy the files between the emulator and PC

40

I
-

4.2. Log in
ddms

View the running log (
ddms
)



you can find the running error or system message here .

// Append
Log.v
() to
OnCreate
() and
OnStart
() method of class
HelloOkinawa_activity
,


@Override


public void
onCreate(Bundle

savedInstanceState
) {


super.onCreate(savedInstanceState
);


setContentView(R.layout.main
);


Log.v("TEST
", "in
onCreate

method...");


}


@Override


protected void
onStart
() {



super.onStart
();



Log.v("TEST
", "in
onStart

method...");


}

Specify a filter “TEST” here

Emulator Control



Telephony actions, Location controls



Switch layout orientation (CTRL+ F11, CTRL + F12)

41

I
-

4.3. Connect to android device by
IP
-

adb

Command line tools:
adb

$
export ADBHOST=
IP



set ADBHOST=
IP



for windows

$
adb

kill
-
server

$
adb

start
-
server

$
adb

devices

Assign an
IP

address to the android device, and connect it to the network.

Confirm the reachability by the following command

$ ping
IP




IP
address of the android
device

42

I
-

4.4. Project files in
the release
version
(on the emulator)

From the command line: $
adb

shell

or open the perspective
ddms

from eclipse

The setting or data of the application is here.

43

I
-

4.5. Files in the release version
-

.
apk

.
apk

is in
.zip

format


Pull down your .
apk

file from the
simulator or device
to your PC, rename
and extract it


44

I
-

4.6. Locale and text

res/drawable
-
xx
-
r
yy

res/values
-
xx


言語
xx
: ISO
-
639
-
1


http://en.wikipedia.org/wiki/

List_of_ISO_639
-
1_codes


地域
yy
: ISO
-
3166
-
alpha
-
1


http://en.wikipedia.org/wiki/ISO_3166
-
1



参考例:
Hello, L10N

http://developer.android.com/intl/ja/resource
s/tutorials/localization/index.html

or http://goo.gl/iZdJ5