Course 03 - PowerPoint PPT Presentation

About This Presentation
Title:

Course 03

Description:

Android (VM) - Active ( ) Activity Activity Android ... – PowerPoint PPT presentation

Number of Views:48
Avg rating:3.0/5.0
Slides: 59
Provided by: csNccuEd6
Category:
Tags: course

less

Transcript and Presenter's Notes

Title: Course 03


1
Course 03
2
Android ????
Android OS Stack
?????????
????????
Activity
????????
Intent
Service
Broadcast Receiver
????
Content Provider
View System??
Layouts
??????
UI s
?????????
3
Android ????
Android OS Stack
?????????
????????
Activity
????????
Intent
Service
Broadcast Receiver
????
Content Provider
View System??
Layouts
??????
UI s
?????????
4
Framework Stack OverView
5
(No Transcript)
6
Linux Kernel
  • Base on Linux 2.6
  • ? ???kernel, ???GPL????(??)
  • Linux ???GNU General Public License version 2
    (GPLv2)
  • Driver???linux userspace,?????????driver source
  • Power Management??
  • ??????
  • ????, ???

7
Libraries
  • Library?c/c??
  • ?????, ???????Application Framework ???????

8
Android Runtime
  • Core Libraries
  • ???Java Programming Language
  • Dalvik Virtual Machine (??DVM)
  • ??????
  • Run(?) on Linux ?Virtual Memory, multiple
    processes
  • ??????(?????)CPU??(not JIT)
  • ????, ?????

9
Application Framework
  • Google??API,?framework????????????????,???app?,???
    ??
  • ???????
  • http//developer.android.com/reference/packages.ht
    ml

10
Applications
  • ?????????-????eMail ?Map ?Calendar ?????
  • ?Market?????
  • ???????

11
Applications(cont.)
  • ??Java language??
  • ????, ?tool/aapt.exe ???.apk
  • Apk -gtapplication
  • ??????
  • ??application????Linux process???
  • ??process????Java VM, isolate from other
    applications
  • ??application??????, ??????application???

12
Android ????
Android OS Stack
?????????
????????
Activity
????????
Intent
Service
Broadcast Receiver
????
Content Provider
View System??
Layouts
??????
UI s
?????????
13
Application Framework????????????
  • ????
  • Activities-?????????????
  • Activity Life Cycle
  • Services-????
  • Services Life Cycle
  • Broadcast receivers -???????
  • Content Provider-????
  • ???? Intent

14
1.Activity
  • ??UI, ???user??
  • ?????button?list?picture?text
  • UI?????(?????????)
  • ??intent?????activity
  • ????????Service, handler, ??5?, ???ANR (Android
    is Not Responding)

Reference Component Lifecycles
15
ActivityLife Cycle
!!!
??-gt???? onCreate() onStart() onResume() ????-gt?
? onPause() onStop() onDestroy()
Reference Component Lifecycles
16
Android ????(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)
24
Intent
  • ????????????????
  • ??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 ?????

26
Service
  • ????????, ?UI??
  • ???ANR???
  • ?
  • ????
  • ????????
  • ??or?????
  • ??bindService(), ?Activity?Service??

27
Broadcast Receiver
  • ??????Intent
  • ??sendBroadcast()??????, ???????
  • ??5sec.???
  • ?????Activity or Service or ????
  • ?
  • Android???????????, ????????
  • ??????????????, ???????, ???????, ???, ???
  • Demo Code\ demo_BroadcastReceiver
  • ?DDMS??????,????

28
Content 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
30
Android ????
Android OS Stack
?????????
????????
Activity
????????
Intent
Service
Broadcast Receiver
????
Content Provider
View System??
Layouts
??????
UI s
App???????
31
View
32
(No Transcript)
33
Views
34
View???UI(Widget)????
http//developer.android.com/intl/zh-TW/reference/
android/widget/TextView.html
Refer http//school.brad.tw/mod/resource/view.php
?id384
35
LayOut-??UI?????
Reference Declaring Layout.
36
LayOut
Reference Declaring Layout.
37
Demo demo code\demo_ChangeLayOutReference
ApiDemo -gtViews -gtLayouts
LayOut
38
View 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)
41
Tabs
42
(No Transcript)
43
ImageView
44
ImageSwitcher
45
Progress Bar
46
Radio Group
47

48
Auto-Completion
49
DatePicker
50
Rating Bar
51
???UI?????????
  • UI Events
  • 1. Define an event listener
  • EX  View.OnClickListener
  • View.OnTouchListener
  • View.OnKeyListener
  • 2.  register it with the View

52
Android ????
Android OS Stack
?????????
????????
Activity
????????
Intent
Service
Broadcast Receiver
????
Content Provider
View System??
Layouts
??????
UI s
?????????
53
package 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
54
public 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

58
Next
Android ????
?????????
?????????
Emulator
Debug Tools
????????
?????App BMI
Demo Code
Plan Design
????
Coding- UI?? ???
??????
??????- Dialog
Activities Intent
??????
Data Storage
???-?????
????-Web Service
Write a Comment
User Comments (0)
About PowerShow.com