Title: Course 03
1Course 03
2Android ????
Android OS Stack
?????????
????????
Activity
????????
Intent
Service
Broadcast Receiver
????
Content Provider
View System??
Layouts
??????
UI s
?????????
3Android ????
Android OS Stack
?????????
????????
Activity
????????
Intent
Service
Broadcast Receiver
????
Content Provider
View System??
Layouts
??????
UI s
?????????
4Framework Stack OverView
5(No Transcript)
6Linux Kernel
- Base on Linux 2.6
- ? ???kernel, ???GPL????(??)
- Linux ???GNU General Public License version 2
(GPLv2) - Driver???linux userspace,?????????driver source
- Power Management??
- ??????
- ????, ???
7Libraries
- Library?c/c??
- ?????, ???????Application Framework ???????
8Android Runtime
- Core Libraries
- ???Java Programming Language
- Dalvik Virtual Machine (??DVM)
- ??????
- Run(?) on Linux ?Virtual Memory, multiple
processes - ??????(?????)CPU??(not JIT)
- ????, ?????
9Application Framework
- Google??API,?framework????????????????,???app?,???
?? - ???????
- http//developer.android.com/reference/packages.ht
ml
10Applications
- ?????????-????eMail ?Map ?Calendar ?????
- ?Market?????
- ???????
11Applications(cont.)
- ??Java language??
- ????, ?tool/aapt.exe ???.apk
- Apk -gtapplication
- ??????
- ??application????Linux process???
- ??process????Java VM, isolate from other
applications - ??application??????, ??????application???
12Android ????
Android OS Stack
?????????
????????
Activity
????????
Intent
Service
Broadcast Receiver
????
Content Provider
View System??
Layouts
??????
UI s
?????????
13Application Framework????????????
- ????
- Activities-?????????????
- Activity Life Cycle
- Services-????
- Services Life Cycle
- Broadcast receivers -???????
- Content Provider-????
- ???? Intent
141.Activity
- ??UI, ???user??
- ?????button?list?picture?text
- UI?????(?????????)
- ??intent?????activity
- ????????Service, handler, ??5?, ???ANR (Android
is Not Responding)
Reference Component Lifecycles
15ActivityLife Cycle
!!!
??-gt???? onCreate() onStart() onResume() ????-gt?
? onPause() onStop() onDestroy()
Reference Component Lifecycles
16Android ????(VM) -???????
- Active (??)
- ?????????? Activity ?,Activity ??????
- ? Android ???,?????????? Activity
????(Active)???(Running)???
Reference http//code.google.com/p/androidbmi/wik
i/LifeCycle
17- Paused (??)
- ?Paused????? Activity ?????,??????????
- ?????Toast?AlertDialog????????,???????? Activity
???????????Toast?AlertDialog??????????? Activity
???Activity ???Paused????,??????? Activity ??? - Demo gt ApiDemo , App/Dialog
18- Stopped (??)
- ?Stopped??????? Activity ????,??? Activity
??????,???????? - ?????Home??,?????????Stopped???????????
- ??Stopped???? Activity,??????Notification?????
19- Dead (???????)
- ?Dead???? Activity ?????????????,????????????
- ????? Activity,?????????finish???
- ????????,???????????,?????????????????,????Stopped
???? Activity ?????????
20(No Transcript)
21????????
22(No Transcript)
23(No Transcript)
24Intent
- ????????????????
- ??Intent???????(action),???????????
- ?
- public void onClick()
-
- Uri uri Uri.parse("http//www.nccu.com.tw/")
- Intent intent new Intent(Intent.ACTION_VIEW,
uri) - startActivity(intent)
-
- ???????, ?Android????????
- Intent Filter ??????Activity????? ?
25- Demo
- demo code -gt demo_Intent
- ??Intent , ??Activity ?????
26Service
- ????????, ?UI??
- ???ANR???
- ?
- ????
- ????????
- ??or?????
- ??bindService(), ?Activity?Service??
27Broadcast Receiver
- ??????Intent
- ??sendBroadcast()??????, ???????
- ??5sec.???
- ?????Activity or Service or ????
- ?
- Android???????????, ????????
- ??????????????, ???????, ???????, ???, ???
- Demo Code\ demo_BroadcastReceiver
- ?DDMS??????,????
28Content Provider
- ?????????
- ?
- ??Contact
- content//contacts/people/45 (???????45??????)
- content//contacts/people/ (???????)
- Demo demo code/demo_ContentProvider
29??Android Framework ??,????App??
1.???????? (Applications) http//www.youtube.com/w
atch?v3aUjukCdPyQ 2.??????? (Intent
filter) http//www.youtube.com/watch?v3LkNlTNHZzE
3.??????????? (webView) http//www.youtube.com/wa
tch?vEx7YsQ_YH2U 4.?????????? (service
??) http//www.youtube.com/watch?v7lScgyXGxwo
Reference http//www.youtube.com/user/androiddev
elopers
30Android ????
Android OS Stack
?????????
????????
Activity
????????
Intent
Service
Broadcast Receiver
????
Content Provider
View System??
Layouts
??????
UI s
App???????
31View
32(No Transcript)
33Views
34View???UI(Widget)????
http//developer.android.com/intl/zh-TW/reference/
android/widget/TextView.html
Refer http//school.brad.tw/mod/resource/view.php
?id384
35LayOut-??UI?????
Reference Declaring Layout.
36LayOut
Reference Declaring Layout.
37Demo demo code\demo_ChangeLayOutReference
ApiDemo -gtViews -gtLayouts
LayOut
38View Widget
- ???????????View Object
- EX Buttons , checkboxes , EditText ,
- EX Date Picker , Clock , Zoom Controls
- ??????,????Widget ?????View Object
- Ref Building Custom Components
39(No Transcript)
40(No Transcript)
41Tabs
42(No Transcript)
43ImageView
44ImageSwitcher
45Progress Bar
46Radio Group
47 48Auto-Completion
49DatePicker
50Rating Bar
51???UI?????????
- UI Events
- 1. Define an event listener
- EX Â View.OnClickListener
- View.OnTouchListener
- View.OnKeyListener
- 2. Â register it with the View
52Android ????
Android OS Stack
?????????
????????
Activity
????????
Intent
Service
Broadcast Receiver
????
Content Provider
View System??
Layouts
??????
UI s
?????????
53package com.demo.android.hello import
android.app.Activity import android.os.Bundle im
port android.view.View import android.widget.Butt
onimport android.widget.TextView
54public class myMainActivity extends Activity
/ Called when the activity is first created.
/ _at_Override public void onCreate(Bundle
savedInstanceState) super.onCreate(saved
InstanceState) setContentView(R.layout.ma
in)
55??1.Button -gt ??
- Demo code -gtpratice00_Button
- Step
- 1. res/-gt Layout/-gt main.xml
- Button , TextView
- ????
- 2. Button ,TextView????,
- 3.??findViewById ??????????????
- 4.??onClickListener ??
- 5.???Button?
56 //2. Button btn_MyButton TextView txt_MyText
//3. btn_MyButton
(Button)findViewById(R.id.Button01)
txt_MyText (TextView)findViewById(R.id.TextView0
1)
//5. btn_MyButton.setOnClickListener(showT
ext)
//4. private View.OnClickListener showText
new OnClickListener() _at_Override publi
c void onClick(View v) // TODO
Auto-generated method stub txt_MyText.setText("
Hello World !")
57??2
- ??,??????,???????,????
- setTextColor()
- http//developer.android.com/intl/zh-TW/reference/
android/widget/TextView.html - Color
- http//developer.android.com/intl/zh-TW/reference/
android/graphics/Color.html
58Next
Android ????
?????????
?????????
Emulator
Debug Tools
????????
?????App BMI
Demo Code
Plan Design
????
Coding- UI?? ???
??????
??????- Dialog
Activities Intent
??????
Data Storage
???-?????
????-Web Service