Android Development

superbshelfMobile - Wireless

Nov 12, 2013 (3 years and 8 months ago)

106 views

Android Introduction

徐旺興

Kimble.hsu@gmail.com

Outline


Mobile Device


Introduce Android


Android development tools


First android program


Framework of Android


Resources



Mobile Device


Windows


Windows CE, Pocket PC, Windows Mobile


Windows 7 Series (2010 Q4)


Nokia
symbian


S60, N97


Maemo
, N900


Apple,
iPhone


Google, Android


Introduce Android (1/2)


http://code.google.com/intl/zh
-
TW/android/


Android Market


Android Phone


HTC Dream (G1)


HTC Magic (G2)


HTC Hero


Samsung i9000


Motorola…




4

Introduce Android (2/2)


Benefit of Open Source


Open Handset Alliance


System Operator


SoC


Hardware Vendor


Software Vendor


Market


Others

ASUS…


Android Developer Challenge


10,000,000 USD


Cab4me,
CompareEveryWhere



5

Android Market


http://www.android.com/market/


Register USD 25


70% and 30%


Beta = Free


Android Phone

build
-
in


6

Market of Mobile Device


Hami

Apps, http://hamiweb.emome.net
/


安卓在線,

http://
www.androidonline.net/


Windows mobile market


Nokia
OVI store, https://store.ovi.com/

Android
v.s
. J2ME


J2ME
發展太慢


JSR
各方意見難有共識


J2ME
沒有官方
Market
平台


...

8

虛擬機器
Dalvik

VM


Android
採用的
VM

J2ME
不同


為了版權,改寫
VM
核心


Android

J2ME
所開發的程式


無法跨平台使用



9

Android
開發工具

SDK
下載

http://developer.android.com/intl/zh
-
TW/sdk/index.html

10

Plug
-
in for
eclipse

ADB (Android Debug Bridge)


設定
Android SDK tools


Windows Path var.


C:
\
android
-
sdk_r04
-
windows
\
android
-
sdk
-
windows
\
tools

(SDK
安裝的位置
)



1

3

2

4

11

The ADB tool

(
常用指令
)


adb

push


a
db

push 001.jpg /
sdcard


adb

pull /
sdcard
/001.jpg .


adb

devices


List all devices connect to PC.


adb

shell


Login android with
adb




Current Directory

at PC

12

The ADB tool

(DDMS/File Explorer)


DDMS

File Explorer

adb

push

adb

pull

Install and Uninstall App. (1/2)


Using
adb

tool


adb

install filename.apk


adb

uninstall
com.android.email


adb

unisstall


k
com.android.email

(keep user’
data)

14

Install and Uninstall App. (2/2)


Using

Manage
applications

on

Android

15

Exercise: Install OI File Manager


Android
模擬器預設沒有安裝檔案總管


http://www.openintents.org/en/download


Download


Install FileManager
-
1.1.1.apk by
adb

tool.(or use
File Explorer of DDMS
)


Run
FileManager

application

16

Android Emulator and DDMS

17

安裝
Eclipse IDE
開發環境


Install
Java (JRE)
+
Eclipse (3.5)
+
Android
Emulator


Download android
SDK 2.2
and
configuration.


Download
ADT 0.9.8
(Eclipse
插件
) and
configuration.


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


http://developer.android.com/intl/zh
-
TW/sdk/index.html



18

AVD Manager


Virtual Device


Installed Packages


Available Packages



Create an AVD

2

3

1

20

Android AVD
安裝路徑


安裝完
android SDK
後,在預設的路徑
下將新增一個
.android
目錄,如:
C:
\
Users
\
kimble
\
.adnroid


上述目錄就是存放
AVD
的路徑。


若要修改存放
AVD
的路徑,需設定環境
變數,如:

ANDROID_SDK_HOME=
C:
\
android
-
sdk
-
windows

第一支
Android
程式


建立一個新的專案


File > New > Project


若是找不到
Android Project (
ADT
沒裝好
)

22

建立專案名稱


應用程式名稱


套件名稱


建立
Activity


SDK Version


23

Android

執行單元

建立模模擬器



Menu Bar
按下

24

建立執行環境



Menu Bar



建立執行環境名稱


Run


25

Example: Hello World


Project Name “
HelloAndroid



Package
Nmae


tw.kimle



Activity name “
HelloAndroid



Application name “My Android”

26

Exercise: Add a Button into

“Hello World” (1/3)


Add a Button into
LinearLayout


若在之後的
程式中控制
這個物件就
要加上
id

<Button


android:id
="
@+id/
btnClickMe
"


android:layout_width
="
fill_parent
"


android:layout_height
="
wrap_content
"


android:text
="Click Me!“

/>

Button
這個
物件的名稱

27

Exercise: Add a Button into

“Hello World” (2/3)

切換

多了一

Button

28

Exercise: Add a Button into

“Hello World” (3/3)



HelloAndroid.java
中加入事件處理



onCreat
()
方法中加入



產生一個
btnListener

Button btn1 = (Button)
findViewById
(
R.id.btnClickMe
);


btn1.setOnClickListener(
btnListener
);

private
OnClickListener

btnListener

= new
OnClickListener
()


{


public void
onClick
(View v)


{


Toast.makeText
(
getBaseContext
(),


"
Hello

World!!!
",


Toast.LENGTH_LONG
).show();


}


};

29

Interface to global
information about
an application
environment

Connect to the android phone


Install USB driver


<android
-
sdk
>
\
usb_driver


Run configuration


HTC G1
手機

Android Framework

31

Resources


Android SDK


http://developer.android.com/intl/zh
-
TW/index.html


Documentation


http://developer.android.com/reference/androi
d/widget/LinearLayout.html


API Demo


<
android_sdk
>
\
platforms
\
android
-
2.0
\
samples
\
ApiDemos