Android Robert C.C. Huang Oscar F.Y. Liu Peter C.L. Hsieh 2011/03/21
Outlines for Today Future Planning Review System Architecture Dev. Tools & Making the First App Project Structure & File Details Application Components Activity : a brief look & life cycle Brief introduction to UI elements
Schedule of Learning 3/21: Review & Ch3 Ch4 Ch5 3/28: Ch6 Ch7 4/4: Ch8 Ch9 4/11: Ch10 4/18: Ch11 Ch12 4/25: Ch13 Ch14
Textbook
Review
System Architecture We will introduce it in a Top-Down order.
System Architecture Applications Top layer Dalvik App App Market App
System Architecture Application Framework Second layer Google API Application View System, Activity System, etc.
System Architecture Libraries Part of the third layer Java ( NDK ) C/C++
System Architecture Android Runtime Part of the third layer Core Libraries Java Dalvik Virtual Machine.dex(Dalvik EXcutable) binary
Dalvik? Dalvik Virtual Machine Android Dalvik Dalvik Java Java Bytecode Java bytecode Dalvik VM dex(dalvik EXcutable).dex dex Dalvik bytecode Java bytecode Java VM JIT Android 2.2.java -> javac ->.class -> dx ->.dex
Linux Kernel(Based on 2.6 series) Bottom layer Android Linux (e.g. ) GPL
Development Tool JDK(Java Development Kit) Eclipse IDE ADT(Android Development Tools plugin) Android SDK
Demo
Making the First App!... BMI Step.1 Describe (Graphic) User Interface...
Making the First App! Step.2 Design User Interface res/layout/xxx.xml Step.3 Access Identifiers res/values/xxx.xml & gen/r.java
Making the First App! Step.4 Design Program Procedure(Flow control) UI src/xxx.java Step.5 Build.apk & Testing
Project Structure
Project Structure src/.java source files gen/ auto-generated files res/ resources(pic, layout, etc.) AndroidManifest.xml App settings
src/ source files Java.java Activity.java Java Class source file
gen/ Auto-generated Java File Eclipse/ADT.java Android XML XML R.java
gen/r.java A project's R.java file is an index into all the resources defined in the file. You use this class in your source code as a sort of shorthand way to refer to resources you've included in your project. This is particularly powerful with the codecompletion features of IDEs like Eclipse because it lets you quickly and interactively locate the specific reference you're looking for. The important thing to notice for now is the inner class named "layout", and its member field "main". The Eclipse plugin noticed that you added a new XML layout file and then regenerated this R.java file. As you add other resources to your projects you'll see R.java change to keep up.
res/ drawable/ layout/ xml values/ XML xml/ XML raw/
Demo
Application Components Activity Service Broadcast receivers Content providers
Activity Android android.app.activity Activity C# Web Activity Android Life Cycle Activity Intent 5 ANR(Android is Not Response) Service
Activity - Active( ) activity activity activity (Active) (Running) Paused( ) activity ex. Stopped( ) activity Activity Stopped activity notification Dead( ) activity finish activity
Android Activity Life Cycle oncreate() onstart() onresume() onpause() onstop() ondestroy()
Activity : (Create/Destroy) (Create) (Destroy) (Start/ReStart/Stop) activity Start activity activity Stop activity activity (Destroy) ReStart Start (Resume/Pause) activity Pause activity Resume
iphone View Life Cycle viewdidload viewwillappear viewdidappeared viewwilldisappear viewdiddisappeared viewdidunload
Activity
Intent Intent (action) Activity Intent Android Intent Intent intent-filter Intent Activity
Service Activity Service Handle 5 ANR /
Broadcast Receivers Intent sendbroadcast(), 5sec Activity or Service or Android,,,,,
Content Providers, Contact content://contacts/people/45 ( : 45 ) content://contacts/people/ ( : )
AndroidManifest.xml Activity
UI Elements AlertDialog Toast Notification Menu Layout
Demo
Thank you!