Course 03 1 Android Android OS Stack Activity
- Slides: 58
Course 03 1
Android現況概述 Android OS Stack 開發環境介紹與熟 悉 四大程式元件簡介 Activity 程式基本框架介紹 Intent Service Broadcast Receiver Content Provider 開發演練 View System 簡介 Layouts 進階應用介紹 UI s 主程式架構說明 &練習
Android現況概述 Android OS Stack 開發環境介紹與熟 悉 四大程式元件簡介 Activity 程式基本框架介紹 Intent Service Broadcast Receiver Content Provider 開發演練 View System 簡介 Layouts 進階應用介紹 UI s 主程式架構說明 &練習 3
Framework Stack Over. View 4
5
Linux Kernel Base on Linux 2. 6 � 已修改kernel, 以避免GPL授權問題(連結) Linux 版權�GNU General Public License version 2 (GPLv 2) Driver移動至linux userspace, 硬體廠商不需要公開driver source Power Management修改 針對手機環境 沒有使用, 就關掉 6
Libraries Library以c/c++開發 屬系統元件, 開發者可以透過Application Framework 來使用這些功能 7
Android Runtime Core Libraries 對應於Java Programming Language Dalvik Virtual Machine (簡稱DVM) 針對手機開發 Run(綁) on Linux � Virtual Memory, multiple processes 執行指令精簡(節省記憶體)&CPU效率(not JIT) 詳細說明, 請看�連結
Application Framework Google提供API, 此framework內已經具備多種不同的 基礎軟體元件,在開發app時,可直接使用 內容可參考網頁 http: //developer. android. com/reference/packages. html 9
Application s(cont. ) 使用Java language開發 編譯完成, 以tool/aapt. exe 包裹為. apk Apk ->application 三種基本特性 每個application在自己的Linux process中執行 每個process有自己的Java VM, isolate from other applications 每個application權限獨立分開, 不能讀取其他application 的檔案 11
Android現況概述 Android OS Stack 開發環境介紹與熟 悉 四大程式元件簡介 Activity 程式基本框架介紹 Intent Service Broadcast Receiver Content Provider 開發演練 View System 簡介 Layouts 進階應用介紹 UI s 主程式架構說明 &練習 12
Application Framework 上 應用程式常用的四大區塊 四大元件: Activities-管理應用程式顯示畫面的類別 Activity Life Cycle Services-服務功能 Services Life Cycle Broadcast receivers -意圖與廣播接收 Content Provider-內容提供 溝通橋樑: Intent 13
1. Activity 包括UI, 以及與user互動 上面可以放button、list、picture、text… UI可動態調整(增加、減少、換位置) 透過intent跳轉至其他activity 費時的程式要放到Service, handler…, 超過5秒, 會出現 ANR (Android is Not Responding) Reference: Component Lifecycles
Activity !!! Life Cycle 啟動->出現畫面 on. Create() on. Start() on. Resume() 關閉畫面->結束 on. Pause() on. Stop() on. Destroy() Reference: Component Lifecycles
Android 的虛擬機 (VM) -主要有四種狀態: Active (活動) 使用者啟動應用程式或 Activity 後,Activity 運行中的狀態 在 Android 平台上,同一個時刻只會有一個 Activity 處於活動(Active)或 運行(Running)狀態。 Reference: http: //code. google. com/p/androidbmi/wiki/Life. Cycle
Intent 用來描述一個程式想要作些什麼事情 每個Intent都帶有一個動作(action),並根據不同的動 作去行動 例 public void on. Click() { Uri uri = Uri. parse("http: //www. nccu. com. tw/"); Intent intent = new Intent(Intent. ACTION_VIEW, uri); start. Activity(intent); } 要開啟一個網頁, 由Android去決定誰要開網頁 Intent Filter : 向系統宣告該Activity可以做甚麼 ? 24
Demo : demo code -> demo_Intent 透過Intent , 達到Activity 之間的切換 25
Content Provider 與其他程式分享資料 例 存取Contact content: //contacts/people/45 (傳回: 聯絡人編號 45的聯絡人記 錄) content: //contacts/people/ (傳回: 全部聯絡人) Demo : demo code/demo_Content. Provider Reference : http: //ysl-paradise. blogspot. com/2008/11/content-provider. html http: //blog. sina. com. cn/s/blog_3 f 7 f 41 d 40100 cnax. html 28
上述 Android Framework 之 下, 所帶來的 App特色 1. 應用程式一律平等 (Applications) http: //www. youtube. com/watch? v=3 a. Ujuk. Cd. Py. Q 2. 應用程式無界限 (Intent filter) http: //www. youtube. com/watch? v=3 Lk. Nl. TNHZz. E 3. 應用程式可輕鬆嵌入網頁 (web. View) http: //www. youtube. com/watch? v=Ex 7 Ys. Q_YH 2 U 4. 應用程式可以平行執行 (service 機制) http: //www. youtube. com/watch? v=7 l. Scgy. XGxwo Reference: http: //www. youtube. com/user/androiddevelopers
Android現況概述 Android OS Stack 開發環境介紹與熟 悉 四大程式元件簡介 Activity 程式基本框架介紹 Intent Service Broadcast Receiver Content Provider 開發演練 View System 簡介 Layouts 進階應用介紹 UI s App權限管理與設定 30
View 31
32
Views 33
View是所有 UI(Widget) 的父 類別 http: //developer. android. com/intl/zh-TW/reference/android/widget/Text. View. html Refer: http: //school. brad. tw/mod/resource/view. php? id=384 34
Lay. Out-決定 UI的排版方式 Reference : Declaring Layout.
Lay. Out 36 Reference : Declaring Layout.
Lay. Out Demo: demo codedemo_Change. Lay. Out Reference: Api. Demo ->Views ->Layouts 37
View – Widget 直接與使用者進行互動的View Object EX: Buttons , checkboxes , Edit. Text , … EX: Date Picker , Clock , Zoom Controls 可以根據需要, 在既有的Widget 上建立新的View Object Ref : Building Custom Components 38
39
40
Tabs 41
42
Image. View 43
Image. Switcher 44
Progress Bar 45
Radio Group 46
47
Auto-Completion Api demo/com. example. android. apis. view 48
Date. Picker 49
Rating Bar 50
如何讓 UI跟使用者產生互 動? UI Events : 1. Define an event listener EX: View. On. Click. Listener View. On. Touch. Listener View. On. Key. Listener 2. register it with the View 51
Android現況概述 Android OS Stack 開發環境介紹與熟 悉 四大程式元件簡介 Activity 程式基本框架介紹 Intent Service Broadcast Receiver Content Provider 開發演練 View System 簡介 Layouts 進階應用介紹 UI s 主程式架構說明 &練習 52
package com. demo. android. hello; import android. app. Activity; import android. os. Bundle; import android. view. View; import android. widget. Button; import android. widget. Text. View; 53
public class my. Main. Activity extends Activity { /** Called when the activity is first created. */ @Override public void on. Create(Bundle saved. Instance. State) { super. on. Create(saved. Instance. State); set. Content. View(R. layout. main); } } 54
練習 1. : Button -> 顯示 Demo code ->pratice 00_Button Step: 1. res/-> Layout/-> main. xml Button , Text. View 程式碼中 2. Button , Text. View實體宣告, 3. 透過find. View. By. Id 從資源檔中取得對應的介面元件 4. 定義on. Click. Listener 事件 5. 註冊到Button中 55
//2. Button btn_My. Button; Text. View txt_My. Text; //3. btn_My. Button = (Button)find. View. By. Id(R. id. Button 01); txt_My. Text = (Text. View)find. View. By. Id(R. id. Text. View 01); //5. btn_My. Button. set. On. Click. Listener(show. Text); //4. private View. On. Click. Listener show. Text = new On. Click. Listener() { @Override public void on. Click(View v) { // TODO Auto-generated method stub txt_My. Text. set. Text("Hello World !"); } };
練習 2 同上, 但顯示文字時, 同時也更換顏色, 字型大小 set. Text. Color() http: //developer. android. com/intl/zh. TW/reference/android/widget/Text. View. html Color http: //developer. android. com/intl/zh. TW/reference/android/graphics/Color. html 57
- Stack smashing vs buffer overflow
- Stack grows downwards
- C++ stack vs heap
- Network stack android
- One brick t junction in english bond
- Course title and course number
- Course interne moyenne externe
- Fragment vs activity android
- Android view lifecycle
- Android activity diagram
- Reactants, products and leftovers
- Activity coefficient
- Activity on node
- Activity 1 introductory activity
- Activity 2 finding the sequence
- Activity 2 plus and minus
- 3
- Eurocircuits.com
- Flip shape visio
- Stack algorithm
- 2 stack pda
- Ssh protocol stack
- Semantic web stack
- Grc stack
- Logstash geo_point
- Contoh program stack struktur data
- What is stack card in warehouse
- Stack
- Stack guard
- Stack smashing
- L pop lll
- Stack smashing for fun and profit
- Aleph one smashing the stack
- Netflix oss architecture
- Wifi stack architecture
- Rootish language
- Non executable stack buffer overflow
- Which is not ranap functionality
- Which organelle looks like a stack of puffy pancakes
- Network stack adalah
- Ns3 training
- Microsoft power bi stack
- Bor equity stack
- Push adalah operasi untuk memasukkan data ke
- Struktur data
- Key metrics in business model canvas
- Ccdstack 2
- Stack grows downwards
- Cloud federation stack
- Stack data structure exercises
- Reticulum network stack
- Push and pop in microprocessor
- Stack and heap memory
- What is dsrc
- Cup stacking rules
- Ssh protocol stack
- Stack based overflow
- Base 8
- Bluetooth protocol stack