58
人人人人 Android Framework 1 http ://www.cs.nccu.edu.tw/~ chenaho/Workshop

人機介面 Android Framework

  • Upload
    clancy

  • View
    83

  • Download
    1

Embed Size (px)

DESCRIPTION

人機介面 Android Framework. http ://www.cs.nccu.edu.tw/~ chenaho/Workshop. Android OS Stack. 四大程式元件簡介. Activity. Intent. Service. Broadcast Receiver. Content Provider. View System 簡介. Layouts. UI s. 主程式架構說明 & 練習. Android OS Stack. 四大程式元件簡介. Activity. Intent. Service. - PowerPoint PPT Presentation

Citation preview

CourseHuman Computer Interaction: Android Framework

Android Framework1http://www.cs.nccu.edu.tw/~chenaho/Workshop

Android OS StackView SystemActivityServiceIntentBroadcast ReceiverContent ProviderLayoutsUI s&Smart Phone, Android , app,workshop,Android ,HardwareAndroid SDK Framework- (Day 3)Google Map Sensors

2Android OS StackView SystemActivityServiceIntentBroadcast ReceiverContent ProviderLayoutsUI s&Smart Phone, Android , app,workshop,Android ,HardwareAndroid SDK Framework- (Day 3)Google Map Sensors

3

Framework Stack Overview4Why choose Linux Kernel ?, Linux Kernel

based on PacketVideo's OpenCORE; the libraries support playback and recording of many popular audio and video formats, as well as static image files, including MPEG4, H.264, MP3, AAC, AMR, JPG, and PNG

WMV,ffxxx Porting45

Linux KernelBase on Linux 2.6 kernel, GPL()Linux GNU General Public License version 2 (GPLv2)Driverlinux userspace,driver source Power Management,

6

LibrariesLibraryc/c++, Application Framework

7

NDK7Android RuntimeCore LibrariesJava Programming LanguageDalvik Virtual Machine (DVM)Run() on Linux Virtual Memory, multiple processes()&CPU(not JIT),

Application FrameworkGoogleAPI,frameworkapphttp://developer.android.com/reference/packages.html

9

Applications-eMail Map Calendar Market10

Applications(cont.)Java language, tool/aapt.exe .apk Apk ->application applicationLinux processprocessJava VM, isolate from other applicationsapplication, application

11Android OS StackActivityServiceIntentBroadcast ReceiverContent ProviderLayoutsUI sAppView SystemSmart Phone, Android , app,workshop,Android ,HardwareAndroid SDK Framework- (Day 3)Google Map Sensors

12Application Framework:Activities-Activity Life CycleServices-Services Life CycleBroadcast receivers -Content Provider-: Intent

13Adnroid -

Activity:EX: ,,,Activity

Intent :,Activity, ,IntentBroadcastReceiverEX: ,IntentBroadcastReceiverEX:Intent + BroadcastReceiver,

Service: EX: MP3

Content Provider:,EX:131.ActivityUI, userbuttonlistpicturetextUI()intentactivityService, handler, 5, ANR (Android is Not Responding)

Reference: Component Lifecycles Android Activity (Active)(Running) Activity (Dead)(Stopped)(Pause)

Active ()Active Activity Activity Android Activity (Active)(Running) Activity (Dead)(Stopped)(Pause)Paused ()Paused Activity ToastAlertDialog Activity ToastAlertDialog Activity Activity Paused Activity Stopped ()Stopped Activity Activity HomeStoppedStopped ActivityNotificationNotificationDead ()Dead Activity ActivityfinishStopped Activity

14ActivityLife Cycle ->onCreate()onStart()onResume()

->onPause()onStop()onDestroy()

Reference: Component Lifecycles

!!!Android (VM) -Active () Activity Activity Android Activity (Active)(Running)

Reference: http://code.google.com/p/androidbmi/wiki/LifeCycle

Android (VM) (Stack based) Active ()Paused ()Stopped ()Dead ()

16Paused ()Paused Activity ToastAlertDialog Activity ToastAlertDialog Activity Activity Paused Activity

Demo => ApiDemo , App/Dialog17

Stopped ()Stopped Activity Activity HomeStoppedStopped ActivityNotification

18

Dead ()Dead Activity ActivityfinishStopped Activity 19

22

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); }, AndroidIntent Filter : Activity ?

24 24Demo : demo code -> demo_IntentIntent , Activity

25Service, UIANRor bindService(), ActivityService

26

Broadcast ReceiverIntentsendBroadcast(),5sec.Activity or Service or Android, , , , , Demo Code\ demo_BroadcastReceiverDDMS,

Reference : http://www.cnblogs.com/xirihanlin/archive/2009/08/03/1537402.html

27Content ProviderContactcontent://contacts/people/45 (:45)content://contacts/people/ (:)Demo : demo code/demo_ContentProvider

Reference :http://ysl-paradise.blogspot.com/2008/11/content-provider.htmlhttp://blog.sina.com.cn/s/blog_3f7f41d40100cnax.html28Android Framework ,App1. (Applications)http://www.youtube.com/watch?v=3aUjukCdPyQ2. (Intent filter)http://www.youtube.com/watch?v=3LkNlTNHZzE3. (webView)http://www.youtube.com/watch?v=Ex7YsQ_YH2U4. (service )http://www.youtube.com/watch?v=7lScgyXGxwo

Reference : http://www.youtube.com/user/androiddevelopers Framework ,Android Apphttp://code.google.com/intl/zh-TW/android/FrameWork

1.

http://www.youtube.com/watch?v=q1m4j676BCcStackView, , ,, Android , Dialog ,

Video : Run Multiple Apps, All At Once on Android- Powered Phones

2.

Intent

Android API intent EX: Babbler Lite

intent,

EX: or or intent , see the video for know more example ~

3.WebView HTMLJavascript (CSS) WebView so , Use Java Script & HTML+CSS to Develop App , is also a Choice

4.Service Android http://developer.android.com/guide/basics/what-is-android.html

29Android OS StackView SystemActivityServiceIntentBroadcast ReceiverContent ProviderLayoutsUI sAppSmart Phone, Android , app,workshop,Android ,HardwareAndroid SDK Framework- (Day 3)Google Map Sensors

30

View31API demo !31

32

Views 33

ViewUI(Widget)34Refer: http://school.brad.tw/mod/resource/view.php?id=384http://developer.android.com/intl/zh-TW/reference/android/widget/TextView.html

LayOut-UIReference : Declaring Layout.

LayOut36Reference : Declaring Layout.LayOutDemo: demo code\demo_ChangeLayOutReference: ApiDemo ->Views ->Layouts

37View WidgetView Object EX: Buttons , checkboxes , EditText ,EX: Date Picker , Clock , Zoom Controls,Widget View ObjectRef : Building Custom Components

3839

40

Tabs41

42

ImageView43

ImageSwitcher44

Progress Bar45

Radio Group46

47

Auto-CompletionApi demo/com.example.android.apis.view 48

DatePicker49

Rating Bar50

UI?UI Events : 1. Define an event listenerEX: View.OnClickListenerView.OnTouchListenerView.OnKeyListener2. register it with the View5152Android OS StackView SystemActivityServiceIntentBroadcast ReceiverContent ProviderLayoutsUI s&5253package com.demo.android.hello;import android.app.Activity;import android.os.Bundle;import android.view.View;import android.widget.Button;import android.widget.TextView;54public class myMainActivity extends Activity { /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); }}1.Button -> Demo code ->pratice00_ButtonStep:1. res/-> Layout/-> main.xmlButton , TextView 2. Button ,TextView, 3.findViewById 4.onClickListener 5.Button55//2.Button btn_MyButton;TextView txt_MyText;//3.btn_MyButton = (Button)findViewById(R.id.Button01);txt_MyText = (TextView)findViewById(R.id.TextView01);//4.private View.OnClickListener showText = new OnClickListener() {@Overridepublic void onClick(View v) {// TODO Auto-generated method stubtxt_MyText.setText("Hello World !");}};//5.btn_MyButton.setOnClickListener(showText);2,,,setTextColor()http://developer.android.com/intl/zh-TW/reference/android/widget/TextView.htmlColorhttp://developer.android.com/intl/zh-TW/reference/android/graphics/Color.html57App BMI EmulatorDebug ToolsPlan & DesignCoding- UI - DialogActivities & IntentData Storage-Demo Code -Web ServiceNEXT58