Java講義

Size: px
Start display at page:

Download "Java講義"

Transcription

1 Android 講義 王振民 目錄 第一章音樂播放程式...3 第一節最陽春的音樂播放程式...3 第一項建立空白的新專案...3 第二項加入 MediaPlayer 物件...3 第二節改善這個程式...5 第一項瞭解 Activity 的生命週期...5 第二項離開程式時也能停止音樂的播放...8 第三項按下播放按鈕才開始播放...8 第二章 google 地圖...12 第一節基本的...12 第一項經度緯度...12 第二項二種定位方式...12 第二節簡單的 GPS 專案...13 第一項 AndroidManifest.xml 檔案...13 第二項介面佈局檔...13 第三項主要程式...14 第三節加強一些的地圖...17 第一項 Main.xml...17 第二項主程式...18 第三章 SQLite 資料庫...23 第一節使用 SharedPreferences...23 第一項介面佈局檔...23 第二項建立主程式的內容 - 儲存偏好設定...24 第三項驗證儲存偏好的動作...25 第四項建立主程式的內容 - 提取偏好設定...26 第二節簡單使用 SQLite...27 第一項介面佈局檔...28 第二項建立 SQLiteOpenHelper 的子類別...28 第三項修改主程式...29 第四項驗證看看 -sqlite3 指令...32 第五項顯示資料表內容...32 Android 講義 v0.5 1 王振民

2 第四章 service...34 第一節建立 MediaPlayer Server...34 第一項修改 androidmanifest.xml 檔案...34 第二項建立 MediaPlayService.java...35 第三項建立主程式...35 Android 講義 v0.5 2 王振民

3 第一章 音樂播放程式 第一節最陽春的音樂播放程式 第一項 建立空白的新專案 1. 請執行 File / New / Project, 選擇 Android / Android Application Project, 建立一個空白的專案 2. 開啟 layout 的介面佈局檔案, 建立一個按鈕, 將它命名為 bt01 (android:id="@+id/bt01"), 將它的顯示文字改為 播放音樂 (android:text=" 播放音樂 ") 3. 在 res 右鍵 / New / Folder, 建立一個 raw 資料夾 4. 請將一個 mp3 檔案複製到 /res/raw/ 底下, 請注意檔案名稱必須符合 res 的命名限制 第二項 加入 MediaPlayer 物件 1. 開啟主程式, 也許是 MainActivity.java, 一開始, 它的內容可能如下 : package com.example.t01music; import android.os.bundle;... 略 public class MainActivity extends Activity { public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); 2. 加入 MediaPlayer 物件的宣告, 請依程式的建議進行相關的 import 動作, 如下 : Android 講義 v0.5 3 王振民

4 package com.example.t01music; import android.media.mediaplayer;... 略 public class MainActivity extends Activity { MediaPlayer mp01 = null; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); 3. 宣告 mp3 的音樂物件, 如下 : package com.example.t01music; import android.media.mediaplayer;... 略 public class MainActivity extends Activity { MediaPlayer mp01 = null; int music01 = R.raw.fir02; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); 4. 在 oncreate() 輸入 findview(); 的敘述, 並依建議動作處理, 產生一個 findview()... 略 的方法 Android 講義 v0.5 4 王振民

5 public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); findview(); private void findview() { 5. 連結 mp3 檔案, 進行播放動作, 參考程式如下 :... 略 private void findview() { mp01 = new MediaPlayer(); mp01 = MediaPlayer.create(this, music01); mp01.start(); 6. 執行程式吧 ~ 聽聽看, 是否有音樂播放出來? 第二節改善這個程式 第一項 瞭解 Activity 的生命週期 以下的流程圖 以及表格, 有助我們瞭解 Activity 的生命週期 Android 講義 v0.5 5 王振民

6 Figure. The activity lifecycle. 資料來源 : Android 講義 v0.5 6 王振民

7 Table. A summary of the activity lifecycle's callback methods. Method Description Killable after? Next oncreate() onrestart() onstart() onresume() onpause() onstop() ondestroy() Called when the activity is first created. This is where you should do all of your normal static set up create views, bind data to lists, and so on. This method is passed a Bundle object containing the activity's previous state, if that state was captured (see Saving Activity State, later). Always followed by onstart(). Called after the activity has been stopped, just prior to it being started again. Always followed by onstart() Called just before the activity becomes visible to the user. No Followed by onresume() if the activity comes to the foreground, or onstop() if it becomes hidden. Called just before the activity starts interacting with the user. At this point the activity is at the top of the activity stack, with user input going to it. Always followed by onpause(). Called when the system is about to start resuming another activity. This method is typically used to commit unsaved changes to persistent data, stop animations and other things that may be consuming CPU, and so on. It should do whatever it does very quickly, because the next activity will not be resumed until it returns. Followed either by onresume() if the activity returns back to the front, or by onstop() if it becomes invisible to the user. Called when the activity is no longer visible to the user. This may happen because it is being destroyed, or because another activity (either an existing one or a new one) has been resumed and is covering it. Followed either by onrestart() if the activity is coming back to interact with the user, or by ondestroy() if this activity is going away. Called before the activity is destroyed. This is the final call that the activity will receive. It could be called either because the activity is finishing (someone called finish() on it), or because the system is temporarily destroying this instance of the activity to save space. You can distinguish between these two scenarios with the isfinishing() method. No No No Yes Yes Yes onstart() onstart() onresume() or onstop() onpause() onresume() or onstop() onrestart() or ondestroy() nothing 資料來源 : Android 講義 v0.5 7 王振民

8 第二項 離開程式時也能停止音樂的播放 剛剛我們所寫的程式, 如果還在播放的狀態, 我們就離開程式, 執行 android 的其它程式, 有沒有注意到, 音樂還在播放! 我們要改善這個狀況, 請依以下動作執行 : 1. 在程式碼的空白處按 右鍵 / Source / Override/Implement Methods 2. 在這裡找一找, 勾選 onpause(), 按 OK, 就會發現在程式碼裡頭, 多出以下 的程式區塊 protected void onpause() { super.onpause(); 3. 請加入以下二行程式 : protected void onpause() { super.onpause(); mp01.stop(); mp01.release(); 4. 再重新執行程式, 在音樂尚未播放完畢前, 離開程式, 如果音樂也就停止播放, 表示 這個動作完成了! 第三項 按下播放按鈕才開始播放 目前的程式, 會在執行時就直接播放音樂, 我們要修改一下, 在按下 播放音樂 時, 才開 始播放, 請依以下動作操作 : 1. 先宣告 Button 類別的 bt01 物件, 再由 R 取出相對應的資源, 指定給 bt01 物件, 再宣 告 bt01 的傾聽程式, 參考如下 :... 略 public class MainActivity extends Activity { MediaPlayer mp01 = null; Android 講義 v0.5 8 王振民

9 int music01 = R.raw.fir02; Button bt01; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); private void findview() { bt01 = (Button) findviewbyid(r.id.bt01); bt01.setonclicklistener(bt01click); mp01 = MediaPlayer.create(this, music01); mp01.start(); protected void onpause() { super.onpause(); mp01.stop(); mp01.release(); 2. 在我們使用 setonclicklistener() 宣告傾聽程式後, 會顯示錯誤訊息, 我們必須手動 輸入程式, 建立 bt01click, 請特別注意的是, 請將 bt01click 當做是一個物件, 它是 經由 Button.OnClickListener 的宣告, 所產生的一個物件, 因此, 最後的大括弧結束 時, 必須再加一個 ; 結束 程式碼參考如下 :... 略 public class MainActivity extends Activity { MediaPlayer mp01 = null; int music01 = R.raw.fir02; Android 講義 v0.5 9 王振民

10 Button bt01;... 略 private void findview() { bt01 = (Button) findviewbyid(r.id.bt01); bt01.setonclicklistener(bt01click); mp01 = MediaPlayer.create(this, music01); mp01.start(); Button.OnClickListener bt01click = new Button.OnClickListener() { ;... 略 3. 系統會提示我們,bt01Click 的物件還需要 Add unimplemented methods, 請依程式的建議處理, 會在 bt01click 物件裡, 再宣告 onclick() 的事件, 這個區塊的程式碼如下 : Button.OnClickListener bt01click = new Button.OnClickListener() { public void onclick(view v) { ; 4. 將 mp01 指定物件與 mp01 播放的二行程式, 移到 bt01click 的 onclick() 方法裡, 同時, 再稍微修改一下程式, 主要是將 MediaPlayer.create(this, music01) 改為 MediaPlayer.create(getApplicationContext(), music01), 將 this 改為 getapplicationcontext() 的原因, 是原本的 MediaPlayer.create() 方法, 是在主要的 Activity 裡執行, 因此只要使用 this 關鍵字就可以取得 這個 Activity 的物件 當我們將 MediaPlayer.create() 方法移到 bt01click 的物件時, this 所參考的物件可能會不正確, 因此, 我們必須將它改為 getapplicationcontext() 方法, 透過呼 Android 講義 v 王振民

11 叫這個方法來取得我們 主要的 Activity 是那一個物件, 這樣一來,mp01 還是可 以正確的取得播放的音樂資源, 進行後續播放的動作 程式碼參考如下 :... 略 public class MainActivity extends Activity {... 略 private void findview() { bt01 = (Button) findviewbyid(r.id.bt01); bt01.setonclicklistener(bt01click);... 略 Button.OnClickListener bt01click = new Button.OnClickListener() { public void onclick(view v) { mp01 = MediaPlayer.create( getapplicationcontext(), mp01.start(); music01); ; 5. 執行程式試試看, 程式執行後, 必須等我們按 播放音樂 的按鈕後, 才會有音樂囉! 練習題 1: 目前有 播放音樂 的按鈕, 請自行建立 停止播放 的按鈕, 而且, 在 按下 停止播放 按鈕時, 要能停止音樂的播放動作 練習題 2: 試試看, 建立一個 暫停 / 播放 的按鈕, 按一下可以暫停音樂的播放, 再按一下, 可以繼續音樂的播放 Android 講義 v 王振民

12 第二章 google 地圖 第一節基本的 第一項 經度緯度 緯度指的是水平的, 由赤道當做 0 度, 往北的方向稱為北緯, 一直到 90 度, 赤道往南, 稱為南緯, 一樣是到 90 度 經度是以倫敦格林威治天文台舊址的南北垂直線, 當做 0 度, 往東 ( 東經 ) 或往西 ( 西經 ) 到 180 度 經度與緯度再細分, 就稱為 分 秒, 概念和時間的分秒相同, 都是以 60 為一個單位, 每 1 度可以細分為 60 分, 每 1 分可以再細分為 60 秒 第二項 二種定位方式 android 提供二種定位方式, 一個是比較精細的 GPS 定位, 使用衛星訊號定位, 另一種是網 路定位, 是使用電信公司基地台, 這種方式比較不精確, 誤差可能的會在一公里左右 Android 講義 v 王振民

13 第二節簡單的 GPS 專案 第一項 AndroidManifest.xml 檔案 這裡需要 android.permission.internet 的使用者授權 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" package="tw.a21" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="15" /> <uses-permission android:name="android.permission.internet"/> <application > <activity android:name=".a21activity" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <uses-library android:name="com.google.android.maps"/> </application> </manifest> 第二項 介面佈局檔 <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > Android 講義 v 王振民

14 <Spinner android:layout_width="match_parent" android:layout_height="wrap_content" android:text=" 請選擇地點 " /> <com.google.android.maps.mapview android:layout_width="match_parent" android:layout_height="wrap_content" android:apikey="0b3hivh5ujuvnk1mho5a-leznlg4qwaiqq4kxwg" /> </LinearLayout> 第三項 主要程式 * 之前的程式都是繼承 Activity, 不過, 在目前的 Google Maps API 這裡, 我們要繼承的類別是 MapActivity * 系統會要我們產生 isroutedisplayed() 的方法 public class A21Activity extends MapActivity { Called when the activity is first created. MapView gm01; // 宣告 MapView 的元件 MapController mc01; // 宣告 MapController 元件 Spinner sp01; // 使用二維陣列的方式, 定訂以下四所大學的座標 String[][] locations = { {" 台灣大學 ", " , ", {" 清華大學 ", " , ", {" 交通大學 ", " , ", {" 成功大學 ", " , " ; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); Android 講義 v 王振民

15 setcontentview(r.layout.main); setupviewcomponent(); setmaplocation(); * 繼承 MapActivity 時, 會需要以下的方法 protected boolean isroutedisplayed() { return false; private void setupviewcomponent() { sp01 = (Spinner) findviewbyid(r.id.sp01); gm01 = (MapView) findviewbyid(r.id.gm01); // 由資源裡取得對應的元件 產生 mc01 的物件 mc01 = gm01.getcontroller(); // 由 gm01 的物件裡, 取得 Controller 的方法, mc01.setzoom(16); // 設定預設的放大倍率是 16 // 這個是要給 spinner 元件使用的字串陣列的中繼器 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.r.layout.simple_spinner_item); // 以下分別將 spinner 裡分別註冊各個項目點選的 Listener for (int i = 0; i < locations.length; i++ ) { adapter.add(locations[i][0]); // 取得各個大學的名稱 adapter.setdropdownviewresource(android.r.layout.simple_dropdown_item_1line); sp01.setadapter(adapter); sp01.setonitemselectedlistener(sp01click); // double lat = ; // 台東巨匠的經度 // double lon = ; // 台東巨匠的緯度 // // int ilat = (int) (lat * 1e6); // 經緯度都乘於 10 的 6 次方 ( 一百萬 ) 的整數 Android 講義 v 王振民

16 // int ilon = (int) (lon * 1e6); // 這是 Google Maps 所接收的值 // // GeoPoint gp01 = new GeoPoint(iLat, ilon); // 將經度緯度轉送給 GeoPoint 類別的 gp01 物件 // mc01.animateto(gp01); // 在地圖裡顯示座標指定的位置 OnItemSelectedListener sp01click = new OnItemSelectedListener() { arg2, public void onitemselected(adapterview<?> arg0, View arg1, int long arg3) { setmaplocation(); public void onnothingselected(adapterview<?> arg0) { ; public void setmaplocation() { int iselect = sp01.getselecteditemposition(); String[] s02 = locations[iselect][1].split(","); double lat = Double.parseDouble(s02[0]); // 緯度 double lon = Double.parseDouble(s02[1]); // 經度 int ilat = (int) (lat * 1e6); // 經緯度都乘於 10 的 6 次方 ( 一百萬 ) 的整數 int ilon = (int) (lon * 1e6); // 這是 Google Maps 所接收的值 GeoPoint gp01 = new GeoPoint(iLat, ilon); // 將經度緯度轉送給 GeoPoint 類別的 gp01 物件 mc01.animateto(gp01); // 在地圖裡顯示座標指定的位置 Android 講義 v 王振民

17 第三節加強一些的地圖 第一項 Main.xml <?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android=" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" > <LinearLayout xmlns:android=" android:layout_width="wrap_content" android:layout_height="wrap_content" android:orientation="horizontal" > <Spinner android:layout_width="match_parent" android:layout_height="wrap_content" android:text=" 請選擇地點 " /> <Spinner android:layout_width="match_parent" android:layout_height="wrap_content" android:text=" 街道圖 " /> </LinearLayout> <com.google.android.maps.mapview android:layout_width="match_parent" android:layout_height="wrap_content" android:apikey="0c9ozd3a32aw Vd7Z70-wu5RJyQKwqux-wT6_Q" android:clickable="true" /> </LinearLayout> Android 講義 v 王振民

18 第二項 主程式 * 之前的程式都是繼承 Activity, 不過, 在目前的 Google Maps API 這裡, 我們要繼承的類別是 MapActivity * 系統會要我們產生 isroutedisplayed() 的方法 * * 另外, 我們在 res/layout/main.xml 那裡, 要新增一個 <com.google.android.maps.mapview /> * public class A22Activity extends MapActivity { Called when the activity is first created. MapView gm01; // 宣告 MapView 的元件 MapController mc01; // 宣告 MapController 元件 Spinner sp01; Spinner sp02; // 這個是要加入定位系統, 所使用的類別 MyLocationOverlay mmylocation; // 使用二維陣列的方式, 定訂以下四所大學的座標 String[][] locations = { {" 台灣大學 ", " , ", {" 清華大學 ", " , ", {" 交通大學 ", " , ", {" 成功大學 ", " , " ; String[] maptype = {" 街道圖 ", " 衛星圖 "; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); setupviewcomponent(); setmaplocation(); Android 講義 v 王振民

19 * 繼承 MapActivity 時, 會需要以下的方法 protected boolean isroutedisplayed() { return false; private void setupviewcomponent() { sp01 = (Spinner) findviewbyid(r.id.sp01); sp02 = (Spinner) findviewbyid(r.id.sp02); gm01 = (MapView) findviewbyid(r.id.gm01); // 由資源裡取得對應的元件 gm01.setbuiltinzoomcontrols(true); // 設定可以由使用者縮放 mc01 = gm01.getcontroller(); // 由 gm01 的物件裡, 取得 Controller 的方法, 產生 mc01 的物件 mc01.setzoom(16); // 設定預設的放大倍率是 16 * 以下程式要加入自己的定位系統. List<Overlay> mapoverlays = gm01.getoverlays(); mmylocation = new MyLocationOverlay(this, gm01); mmylocation.runonfirstfix(new Runnable() { public void run() { // 將自己的位置傳送到 MapController 元件. mc01.animateto(mmylocation.getmylocation()); ); mapoverlays.add(mmylocation); // 這個是要給 sp01 元件使用的字串陣列的中繼器 ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.r.layout.simple_spinner_item); // 取得各個大學的名稱 for (int i = 0; i < locations.length; i++ ) { adapter.add(locations[i][0]); // 以下註冊 sp01 項目點選的 Listener Android 講義 v 王振民

20 adapter.setdropdownviewresource(android.r.layout.simple_dropdown_item_1line); sp01.setadapter(adapter); sp01.setonitemselectedlistener(sp01click); // 這個是要給 sp02 元件使用的字串陣列的中繼器 adapter = new ArrayAdapter<String>(this, android.r.layout.simple_spinner_item); // 取得各個地圖類型的名稱 for (int i = 0; i < maptype.length; i++ ) { adapter.add(maptype[i]); // 以下註冊 sp02 項目點選的 Listener adapter.setdropdownviewresource(android.r.layout.simple_dropdown_item_1line); sp02.setadapter(adapter); sp02.setonitemselectedlistener(sp02click); // double lat = ; // 台東巨匠的經度 // double lon = ; // 台東巨匠的緯度 // // int ilat = (int) (lat * 1e6); // 經緯度都乘於 10 的 6 次方 ( 一百萬 ) 的整數 // int ilon = (int) (lon * 1e6); // 這是 Google Maps 所接收的值 // // GeoPoint gp01 = new GeoPoint(iLat, ilon); // 將經度緯度轉送給 GeoPoint 類別的 gp01 // // 物件 // mc01.animateto(gp01); // 在地圖裡顯示座標指定的位置 public void setmaplocation() { int iselect = sp01.getselecteditemposition(); String[] s02 = locations[iselect][1].split(","); double lat = Double.parseDouble(s02[0]); // 緯度 double lon = Double.parseDouble(s02[1]); // 經度 int ilat = (int) (lat * 1e6); // 經緯度都乘於 10 的 6 次方 ( 一百萬 ) 的整數 int ilon = (int) (lon * 1e6); // 這是 Google Maps 所接收的值 Android 講義 v 王振民

21 類別的 gp01 物件 GeoPoint gp01 = new GeoPoint(iLat, ilon); // 將經度緯度轉送給 GeoPoint mc01.animateto(gp01); // 在地圖裡顯示座標指定的位置 // OnItemSelectedListener sp01click = new OnItemSelectedListener() { arg2, public void onitemselected(adapterview<?> arg0, View arg1, int long arg3) { setmaplocation(); public void onnothingselected(adapterview<?> arg0) { ; OnItemSelectedListener sp02click = new OnItemSelectedListener() { arg2, public void onitemselected(adapterview<?> arg0, View arg1, int long arg3) { switch (arg2) { case 0: gm01.setsatellite(false); // 設定為道路圖 break; case 1: gm01.setsatellite(true); break; // 設定為衛星圖 default: break; Android 講義 v 王振民

22 public void onnothingselected(adapterview<?> arg0) { ; public boolean onkeydown(int keycode, KeyEvent event) { int nextzoom=1, zoom=1; switch (keycode) { case KeyEvent.KEYCODE_I: * 如果按 I 的話, 表示要放大, 會將現在的倍率加 1 nextzoom = gm01.getzoomlevel() + 1; * if (nextzoom > gm01.getmaxzoomlevel()) { zoom = gm01.getmaxzoomlevel(); else { zoom = nextzoom; break; case KeyEvent.KEYCODE_O: * 如果按 O 的話, 表示要放大, 會將現在的倍率減 1 nextzoom = gm01.getzoomlevel() - 1; if (nextzoom < 1) { zoom = 1; else { zoom = nextzoom; break; default: break; Android 講義 v 王振民

23 mc01.setzoom(zoom); return super.onkeydown(keycode, event); protected void onresume() { super.onresume(); mmylocation.enablemylocation(); protected void onstop() { mmylocation.disablemylocation(); super.onstop(); 第三章 SQLite 資料庫 在介紹 SQLite 之前, 我們先來認識 SharedPreferences( 存取偏好設定 ) 第一節使用 SharedPreferences 請建立新的專案, 分別再依以下動作進行 第一項 介面佈局檔 1. 建立 TextView, 顯示文字為 姓名 Android 講義 v 王振民

24 2. 建立 EditText, 設定 id 為 et01 3. 建立 TextView, 顯示文字為 興趣 4. 建立 EditText, 設定 id 為 et02 5. 建立 Button, 設定 id 為 bt01, 顯示文字為 儲存偏好設定 6. 執行程式, 看看是否可以正常顯示介面佈局檔的內容 第二項 建立主程式的內容 - 儲存偏好設定 1. 請開啟主程式, 進行 et01 et02 bt01 等物件的宣告 物件的實體建立, 並且將 bt01 設定傾聽程式, 參考程式碼如下 : public class MainActivity extends Activity { EditText et01; EditText et02; Button bt01; public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); findview(); private void findview() { et01 = (EditText) findviewbyid(r.id.et01); et02 = (EditText) findviewbyid(r.id.et02); bt01 = (Button) findviewbyid(r.id.bt01); bt01.setonclicklistener(bt01click); Button.OnClickListener bt01click = new Button.OnClickListener() { Android 講義 v 王振民

25 public void onclick(view v) { ; 2. 在 bt01click 方法裡輸入相關程式, 參考範例程式如下 : Button.OnClickListener bt01click = new Button.OnClickListener() { public void onclick(view v) { // 將資料儲存到 SharedPreferences 的 sp01 物件. SharedPreferences sp01 = getsharedpreferences("t04shareprefs", 0); sp01.edit().putstring("et01text", et01.gettext().tostring()).putstring("et02text", et02.gettext().tostring()).commit(); // 顯示一個 Toast, 一秒鐘. Toast.makeText(getApplicationContext(), " 資料儲存完成 ", Toast.LENGTH_SHORT).show(); ; 3. 執行程式, 在二個欄位裡輸入資料, 再按一下 bt01, 使系統觸發事件, 執行 bt01click 的動作 第三項 驗證儲存偏好的動作 前項動作執行後, 我們可以驗證看看 驗證動作如下 : Android 講義 v 王振民

26 1. 開啟命令提示字元 2. 執行 adb shell 如果沒有執行 顯示找不到命令的話, 表示系統的 path 路徑沒有指定到 adb 的位置 adb 的程式是放在 android-sdk 目錄下的 platformtools 的目錄裡, 可以手動切換路徑 也可以考慮將它的路徑加入到 path 環境變數裡 3. 進入到 adb shell 後, 可以執行 ls -l 顯示目錄裡的內容, 使用 cd 執行切換工作目錄 以我的例子來看, 我需要先執行 cd /data/data, 在這裡就會看到系統所安裝的所有資料夾, 一個程式會有一個資料夾, 資料夾的名稱就是 package name 4. 我的 package name 是 com.example.t04sharepreference, 因此, 我就需要再輸入 cd com.example.t04sharepreference, 再使用 ls -l 顯示目錄裡的內容, 會看到有一個 shared_prefs 目錄, 裡頭有一個 t04shareprefs.xml 的檔案, 這個檔案就是我們所儲存的偏好設定, 它是一個標準 xml 格式的檔案 5. 我們可以執行 cat t04shareprefs.xml 看看裡頭的內容, 其實就是我們在 android 的程式裡所輸入的內容 第四項 建立主程式的內容 - 提取偏好設定 我們會希望程式每次執行時, 都能先將前次所儲存的偏好設定, 主動的讀取出來, 程式撰寫 的動作如下 : 1. 我們在 findview 方法裡, 呼叫一個 loadsharedprefs 的方法, 參考程式碼如下 : private void findview() { et01 = (EditText) findviewbyid(r.id.et01); et02 = (EditText) findviewbyid(r.id.et02); bt01 = (Button) findviewbyid(r.id.bt01); bt01.setonclicklistener(bt01click); loadsharedprefs(); private void loadsharedprefs() { 2. 在 loadsharedprefs 方法裡, 使用 Android 講義 v 王振民

27 private void loadsharedprefs() { * 第 1 個參數設定我們的偏好設定的檔案名稱是 t04shareprefs, * 第 2 個參數表示只允許程式本身開啟, 不允許其它程式使用. SharedPreferences sp01 = getsharedpreferences("t04shareprefs", 0); * 取得之前儲存的資料, 如果沒有的話, 預設傳回 " 請輸入資料 " 的字串 * 這裡為了簡單及方便理解, 因此另外宣告二個字串變數儲存資料 String s01 = sp01.getstring("et01text", " 請輸入資料 "); String s02 = sp01.getstring("et02text", " 請輸入資料 "); et01.settext(s01.tostring()); et02.settext(s02.tostring()); 3. 請先離開程式, 再重新執行程式, 應該會發現前次輸入的資料會自動填入到 et01 與 et02 的欄位裡 練習題 : 目前的偏好設定儲存, 必須按下 儲存偏好設定 的按鈕, 才會有作用, 請 將程式修改, 當使用者直接離開程式時, 也能由程式將資料儲存後再離開程式 第二節簡單使用 SQLite 我們要使用 SQLite 的話, 需要使用 SQLiteOpenHelper 以及 SQLiteDatabase 這二個類別來建立 以及存取資料庫, 其中的 SQLiteOpenHelper 是一個幫助類別 (Helper Class), 我們需要建立一個繼承自 SQLiteOpenHelper 的類別,SQLiteOpenHelper 主要的目的是協助我們建立資料表, 以及資料庫的版本管理 由 SQLiteOpenHelper 所建立出來的資料庫, 是一個 SQLiteDatabase 類別的物件, 因此, 我們可以透過 SQLiteDatabase 所提供的方法該行新增 刪除 更新資料表的內容 以下請建立新專案, 再依照底下的動作進行 Android 講義 v 王振民

28 第一項 介面佈局檔 1. 建立一個 TextView, 顯示文字為 只存記事本 2. 建立一個 EditText, 設定 id 為 et01, 顯示文字為空的 3. 建立一個 Button, 設定 id 為 bt01, 顯示文字為 儲存記事 4. 建立一個 TextView, 設定 id 為 tv01 第二項 建立 SQLiteOpenHelper 的子類別 1. 在 src / 套件名稱 按 右鍵 / New / Class 2. 在 Name 的欄位輸入 mydbhelper, 做為類別的名稱 3. 按 Superclass 右方的 Browse 在上方的 Choose a type 欄位輸入 SQLiteOpenHelper, 底下的 Matching items 會顯示符合的項目, 點選該項目, 按 OK 5. 按 Finish, 建立類別, 同時, 依系統的建議, 修正錯誤的訊息 6. 目前為止, 程式碼類似以下內容 : public class mydbhelper extends SQLiteOpenHelper { public dbhelper(context context, String name, CursorFactory factory, int version) { super(context, name, factory, version); // TODO Auto generated constructor stub public void oncreate(sqlitedatabase arg0) { public void onupgrade(sqlitedatabase arg0, int arg1, int arg2) { 7. 修改 oncreate() 的方法 ( 也就是覆寫父類別的方法 ), 我們要建立自己要使用的資料 Android 講義 v 王振民

29 表, 程式碼參考如下, 其中的 arg0 是系統在 oncreate 方法裡自行宣告的一個 SQLiteDatabase 物件, 我是直接使用這個名稱, 也可以修改物件的名稱 ( 例如改為 db), 使物件名稱比較具有意義 : public void oncreate(sqlitedatabase arg0) { arg0.execsql( "Create Table t05note (" + "_id integer primary key autoincrement, " + "tnote text)" ); 8. 修改 onupgrade 方法, 內容參考如下 : public void onupgrade(sqlitedatabase arg0, int arg1, int arg2) { arg0.execsql("drop Table if exists t05note"); oncreate(arg0); 9. 這個檔案完成了 第三項 修改主程式 1. 宣告各個物件 以及建立 findview 方法, 參考如下 : public class MainActivity extends Activity { SQLiteDatabase db01; mydbhelper dbhelper01; String databasetable = "t05note"; EditText et01; TextView tv01; Button bt01; Android 講義 v 王振民

30 public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); findview(); private void findview() { 2. 建立 findview 方法裡的各個物件的實體, 參考程式碼如下 : private void findview() { et01 = (EditText) findviewbyid(r.id.et01); tv01 = (TextView) findviewbyid(r.id.tv01); bt01 = (Button) findviewbyid(r.id.bt01); dbhelper01 = new mydbhelper(this, databasetable, null, 1); db01 = dbhelper01.getwritabledatabase(); 3. 執行程式看看, 應該能正常執行, 而且, 我們可以開啟命令提示字元視窗, 驗證看看資料庫是否己經建立完成, 指令參考如下 : A. 執行 adb shell 進入 android 的模擬器的系統 B. 再執行 cd /data/data/ C. 輸入 ls -l 查看應該有一個和 package name 相同的目錄, 以我的為例, 我會看到 com.example.t05sqlite 的目錄 D. 執行 cd com.example.t05sqlite, 再輸入 ls -l 查看, 應該會產生一個 databases 的資料夾, 而且, 裡頭會有個 t05note 的檔案 E. 看到有 databases 的資料夾, 而且裡頭有個 t05note 的檔案, 就表示有呼叫 SQLite 建立資料庫, 也建立好了資料表 4. 在程式碼的空白處按 右鍵 / Source / Override/Implement Methods, 勾選 Android 講義 v 王振民

31 onstop(), 按 OK 5. 在 onstop 的方法裡, 我們要關閉資料庫, 釋放資源, 參考程式碼如下 : protected void onstop() { super.onstop(); db01.close(); 6. 建立 bt01click 事件, 參考如下 : private void findview() { et01 = (EditText) findviewbyid(r.id.et01); tv01 = (TextView) findviewbyid(r.id.tv01); bt01 = (Button) findviewbyid(r.id.bt01); dbhelper01 = new mydbhelper(this, databasetable, null, 1); db01 = dbhelper01.getwritabledatabase(); bt01.setonclicklistener(bt01click); Button.OnClickListener bt01click = new Button.OnClickListener() { public void onclick(view v) { ; 7. 建立 bt01click 裡的 onclick 事件, 參考如下 : Button.OnClickListener bt01click = new Button.OnClickListener() { public void onclick(view v) { long id; Android 講義 v 王振民

32 ContentValues cv01 = new ContentValues(); cv01.put("tnote", et01.gettext().tostring()); id = db01.insert(databasetable, null, cv01); Toast.makeText(getApplicationContext(), " 記錄新增完成 :" + id, Toast.LENGTH_SHORT).show(); ; 8. 執行程式, 輸入一些文字, 再按 儲存記事, 應該會顯示 記錄新增完成 : x 的 toast 第四項 驗證看看 -sqlite3 指令 前項動作, 我們使用命令提示字元模式, 查看 databases 目錄與 t05note 檔案, 從這個狀態可以再做更細的驗證動作, 請依以下動作操作 : 1. 輸入 sqlite3 t05note, 會進入 sqlite 的命令提示的環境 2. 畫面顯示, 可以輸入.help 取得一些協助, 試試看 3. 輸入.databases, 可以查看我們目前取用的資料庫 4. 輸入.tables, 可以得知我們目前有那些資料表 5. 一般的 sql 指令, 例如新增 刪除, 在這裡是可以通用的, 例如輸入 select * from t05note;, 就可以顯示所有記錄 6. 輸入.quit 可以離開 sqlite3 的命令提示環境 第五項 顯示資料表內容 1. 在 findview 方法裡, 呼叫 showtables 方法, 參考如下 : private void findview() { et01 = (EditText) findviewbyid(r.id.et01); tv01 = (TextView) findviewbyid(r.id.tv01); bt01 = (Button) findviewbyid(r.id.bt01); Android 講義 v 王振民

33 dbhelper01 = new mydbhelper(this, databasetable, null, 1); db01 = dbhelper01.getwritabledatabase(); bt01.setonclicklistener(bt01click); showtables(); private void showtables() { 2. 建立 showtables 方法裡的程式碼, 參考如下 : private void showtables() { String[] colnames = new String[] {"_id", "tnote"; String s01 = ""; Cursor c01 = db01.query(databasetable, colnames, null, null, null, null, null); for (int i=0; i<colnames.length; i++) { s01 = s01 + colnames[i] + "\t"; s01 = s01 + "\n"; c01.movetofirst(); for (int i=0; i<c01.getcount(); i++) { // s01 = s01 + c01.getstring( c01.getcolumnindex( colnames[0] ) ) + "\t"; s01 = s01 + c01.getstring(0) + "\t"; s01 = s01 + c01.getstring(1) + "\n"; c01.movetonext(); tv01.settext(s01.tostring()); 3. 執行程式看看, 應該可以列出所有的記錄 Android 講義 v 王振民

34 第四章 ser vice 第一節建立 MediaPlayer Server 第一項 修改 androidmanifest.xml 檔案 <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android=" package="tw.a17" android:versioncode="1" android:versionname="1.0" > <uses-sdk android:minsdkversion="15" /> <application > <activity android:name=".a17activity" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity> <service android:name="mediaplayservice" android:enabled="true" > </service> </application> </manifest> Android 講義 v 王振民

35 第二項 建立 MediaPlayService.java public class MediaPlayService extends Service { private MediaPlayer player; public void ondestroy() { super.ondestroy(); player.stop(); public int onstartcommand(intent intent, int flags, int startid) { File file = new File("/sdcard/londonkaleb.mp3"); player = MediaPlayer.create(this, Uri.fromFile(file)); player.start(); return super.onstartcommand(intent, flags, startid); public IBinder onbind(intent arg0) { return null; 第三項 建立主程式 public class A17Activity extends Activity { Called when the activity is first created. // 宣告一個 intent 的物件. 按 menu 功能鍵, 呼叫 service 時會使用. Intent i01; LinearLayout ll01; Android 講義 v 王振民

36 TextView tv01; * 這裡設定的動作, 其實就是在指定它的數值. * 其中, Menu.FIRST 等於 1, 其餘繼續遞增. private static final int MENU_MUSIC = Menu.FIRST, MENU_PLAY_MUSIC = Menu.FIRST + 1, MENU_STOP_PLAYING_MUSIC = Menu.FIRST + 2, MENU_ABOUT = Menu.FIRST + 3, MENU_EXIT = Menu.FIRST + 4; public boolean oncreateoptionsmenu(menu menu) { 件. * 在 oncreateoptionsmenu(menu menu) 這裡, 已經幫我們建立了一個 menu 的物 * 所以這裡就是使用 menu 物件來新增功能表. * 如果要新增子功能表的話, 必須使用 SubMenu 的物件, * 再某一個功能項目下, 再新增子功能表. SubMenu submenu; * 在 menu.addsubmenu() 這裡, 先登錄一個功能項目為背景音樂, * 同時也設定這個功能項目, 是具有子功能項目的. * 括弧裡共有四個參數, 分別表示如下 : * int groupid, 透過這裡建立功能表的群組, 這裡統一設定為 0 * int itemid, 這是它的 ID 號碼, 必須是唯一的. * int order, 顯示功能表的順序. * CharSequence title, 顯示的文字內容. submenu = menu.addsubmenu(0, MENU_MUSIC, 0, " 背景音樂 ").seticon(android.r.drawable.ic_media_ff); // 以下分別增加第 1, 2 個子功能項目. submenu.add(0, MENU_PLAY_MUSIC, 0, " 播放背景音樂 "); submenu.add(0, MENU_STOP_PLAYING_MUSIC, 1, " 停止播放背景音樂 "); // 以下分別增加第 2, 3 個功能項目 Android 講義 v 王振民

37 menu.add(0, MENU_ABOUT, 1, " 關於這個程式...").setIcon(android.R.drawable.ic_dialog_info); menu.add(0, MENU_EXIT, 2, " 結束 ").seticon(android.r.drawable.ic_menu_close_clear_cancel); * 將剛才所建立的 menu 物件回傳. return super.oncreateoptionsmenu(menu); public boolean onoptionsitemselected(menuitem item) { * 當選擇功能項目時, 會到這裡執行. * 依我們點選的項目 ID, 這裡會執行不同的程式. switch (item.getitemid()) { case MENU_PLAY_MUSIC: * 啟動 MediaPlayService 的 service. * 因此, 不要忘了要在 androidmanifest 這裡加入 service 的宣告. i01 = new Intent(A17Activity.this, MediaPlayService.class); startservice(i01); break; case MENU_STOP_PLAYING_MUSIC: * 停止 service i01 = new Intent(A17Activity.this, MediaPlayService.class); stopservice(i01); break; case MENU_ABOUT: * 建立一個 AlertDialog 對話框. new AlertDialog.Builder(A17Activity.this).setTitle(" 關於這個程式 ").setmessage(" 選單範例程式 ") Android 講義 v 王振民

38 .setcancelable(false).seticon(android.r.drawable.star_big_on).setpositivebutton(" 確定 ", new DialogInterface.OnClickListener() { public void onclick(dialoginterface dialog, int which) { // TODO Auto-generated method stub break; ).show(); case MENU_EXIT: finish(); break; default: break; return super.onoptionsitemselected(item); public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main); setupviewcomponent(); private void setupviewcomponent() { ll01 = (LinearLayout) findviewbyid(r.id.ll01); tv01 = (TextView) findviewbyid(r.id.tv01); * 所有需要使用 ContextMenu 的元件, 都需要先進行註冊的動作. * 執行 registerforcontextmenu 將元件註冊要進行 ContextMenu 的動作. registerforcontextmenu(ll01); Android 講義 v 王振民

39 registerforcontextmenu(tv01); public boolean oncontextitemselected(menuitem item) { * 由於功能表做的事情相同, 因此, 這裡就省略不做判斷的動作, * 直接呼叫前面的 onoptionsitemselected 方法, * 再將這裡的 item 物件傳給它, 由它來處理 ~~ onoptionsitemselected(item); return super.oncontextitemselected(item); public void oncreatecontextmenu(contextmenu menu, View v, ContextMenuInfo menuinfo) { super.oncreatecontextmenu(menu, v, menuinfo); if (v == ll01) { * 就整個介面佈局來看, LinearLayout 是最底層的, * 再上來是 TextView 的元件, 因此, 當我們在 TextView 上長按, * 會先觸發上層 TextView 的動作, * 再往下傳遞觸發底層的 LinearLayout 的動作. if (menu.size() == 0) { 的. * 以下的動作, 其實和最上方的 oncreateoptionsmenu 的動作是相同 SubMenu submenu; // 建立第 1 個功能項目, 並設定具有子功能表 submenu = menu.addsubmenu(0, MENU_MUSIC, 0, " 背景音樂 ").seticon(android.r.drawable.ic_media_ff); // 以下分別增加第 1, 2 個子功能項目. Android 講義 v 王振民

40 樂 "); submenu.add(0, MENU_PLAY_MUSIC, 0, " 播放背景音樂 "); submenu.add(0, MENU_STOP_PLAYING_MUSIC, 1, " 停止播放背景音 // 以下分別增加第 2, 3 個功能項目 menu.add(0, MENU_ABOUT, 1, " 關於這個程式...").setIcon(android.R.drawable.ic_dialog_info); menu.add(0, MENU_EXIT, 2, " 結束 ").seticon(android.r.drawable.ic_menu_close_clear_cancel); else if (v == tv01) { menu.add(0, MENU_ABOUT, 1, " 關於這個程式..."); Android 講義 v 王振民

41 Android 講義 v 王振民

Android Service

Android Service Android Service- 播放音樂 建國科技大學資管系 饒瑞佶 2013/7 V1 Android Service Service 是跟 Activity 並行 一個音樂播放程式若沒使用 Service, 即使按 home 鍵畫面離開之後, 音樂還是照播 如果再執行一次程式, 新撥放的音樂會跟先前撥放的一起撥, 最後程式就會出錯 執行中的程式完全看不到! 但是, 寫成 Service 就不同了

More information

主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new

主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new ListView 自訂排版 主程式 : public class Main3Activity extends AppCompatActivity { ListView listview; // 先整理資料來源,listitem.xml 需要傳入三種資料 : 圖片 狗狗名字 狗狗生日 // 狗狗圖片 int[] pic =new int[]{r.drawable.dog1, R.drawable.dog2,

More information

Java講義

Java講義 Android 講義 2012.11.11 目錄 第一章 android 的第一次接觸...3 第一節 Windows 7 安裝 Android SDK 開發環境...3 第一項安裝 jdk...3 第二項設定 jdk 的環境變數...4 第三項安裝 Android SDK...8 第四項安裝 eclipse...11 第五項在 eclipse 安裝 ADT plugin...13 第二節建立 AVD

More information

第 2 節 介面佈局檔 第 1 項 說明 第 2 項 原始碼 第 3 節 主程式開發 第 1 項 主程式 - 基本設定 第 2 項 主程式 - 產生亂數 第 3 項 主程式 - 數字靠邊 數字加總 第 4 節 加入手

第 2 節 介面佈局檔 第 1 項 說明 第 2 項 原始碼 第 3 節 主程式開發 第 1 項 主程式 - 基本設定 第 2 項 主程式 - 產生亂數 第 3 項 主程式 - 數字靠邊 數字加總 第 4 節 加入手 Android 講義 2016.07.03 目錄 第 1 章 資料存取... 1 第 1 節 使用 SharedPreferences... 1 第 1 項 介面佈局檔... 1 第 2 項 建立主程式的內容 - 儲存偏好設定... 1 第 3 項 驗證儲存偏好的動作... 3 第 4 項 建立主程式的內容 - 提取偏好設定... 3 第 2 節 簡單使用 SQLite... 5 第 1 項 介面佈局檔...

More information

Dynamic Layout in Android

Dynamic Layout in Android Dynamic Layout in Android 建國科技大學資管系 饒瑞佶 2013/5 V1 Layout 多半都透過 res/layout/xml 格式設定來達成 Android 是 OOP, 所以可以動態產生 Layout 重點是 Layout 的階層關係 (Hierarchy) 需要處理對應事件 最後一樣用 setcontentview 加入 Layout 一 加入現有 Layout 中

More information

單步除錯 (1/10) 打開 Android Studio, 點選 Start a new Android Studio project 建立專案 Application name 輸入 BMI 點下 Next 2 P a g e

單步除錯 (1/10) 打開 Android Studio, 點選 Start a new Android Studio project 建立專案 Application name 輸入 BMI 點下 Next 2 P a g e Android Studio Debugging 本篇教學除了最基本的中斷點教學之外, 還有條件式中斷的教學 條件式中斷是進階的除錯技巧, 在某些特定情況中, 我們有一個函數可能會被呼叫數次, 但是我們只希望在某種條件成立時才進行中斷, 進而觀察變數的狀態 而條件式中斷這項技巧正是符合這項需求 本教學分兩部分 單步除錯 (Page2~11, 共 10) 條件式中斷點 (Page12~17, 共 6)

More information

res/layout 目录下的 main.xml 源码 : <?xml version="1.0" encoding="utf 8"?> <TabHost android:layout_height="fill_parent" xml

res/layout 目录下的 main.xml 源码 : <?xml version=1.0 encoding=utf 8?> <TabHost android:layout_height=fill_parent xml 拓展训练 1- 界面布局 1. 界面布局的重要性做应用程序, 界面是最基本的 Andorid 的界面, 需要写在 res/layout 的 xml 里面, 一般情况下一个 xml 对应一个界面 Android 界面布局有点像写 html( 连注释代码的方式都一样 ), 要先给 Android 定框架, 然后再在框架里面放控件,Android 提供了几种框架,AbsoluteLayout,LinearLayout,

More information

Database_001

Database_001 作者 : 林致宇日期 :2011/10/26 主要參考來源 : http://www.reigndesign.com/blog/using-your-own-sqlite-database-in-android-applicat ions/ 問題 : 如在存取一個已經建立好的資料庫? 解答 : 有一些應用程式會需要讀取已經建立好的資料庫, 例如一個試題測驗應用程式, 裡面的試題可能已經於電腦上, 使用任何的

More information

Microsoft PowerPoint - ch6 [相容模式]

Microsoft PowerPoint - ch6 [相容模式] UiBinder wzyang@asia.edu.tw UiBinder Java GWT UiBinder XML UI i18n (widget) 1 2 UiBinder HelloWidget.ui.xml: UI HelloWidgetBinder HelloWidget.java XML UI Owner class ( Composite ) UI XML UiBinder: Owner

More information

實作SQLiteOpenHelper類別

實作SQLiteOpenHelper類別 SQLiteOpenHelper 類別存取 SQLite 建國科技大學資管系 饒瑞佶 2013/5 V1 Android 連結資料庫 MySQL SQL Server Web Service 遠端資料庫 Internet Intranet Android SQLite 單機資料庫 Android vs. SQLite 透過 SQLiteOpenHelper 類別來操作 建立資料庫 ( 建構子 ) 建立資料表

More information

投影片 1

投影片 1 資料庫管理程式 ( 補充教材 -Part2) 使用 ADO.NET 連結資料庫 ( 自行撰寫程式碼 以實現新增 刪除 修改等功能 ) Private Sub InsertButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles InsertButton.Click ' 宣告相關的 Connection

More information

Android Fragment

Android Fragment Android Fragment 建國科技大學資管系饒瑞佶 2017/10 V1 Android 3.0 後才支援 Fragment 解決部分 App 適應螢幕大小的問題 它類似於 Activity, 可以像 Activity 可以擁有自己的版面設計, 也和 Activity 一樣有自己的生命週期 ( 具備 oncreate() oncreateview() 與 onpause() 方法 ) LifeCycle

More information

建立Android新專案

建立Android新專案 經濟部工業局 Android 智慧型手機程式設計實務應用班 Android WebService 建國科技大學資管系 饒瑞佶 2012/4 WebService 需要 ksoap2-android-assembly-2.5.2-jar-withdependencies.jar 或 ksoap2-android-assembly-2.5.2-jar-withdependencies_timeout1.jar

More information

任務二 : 產生 20 個有炸彈的磚塊, 放在隨機的位置編輯 Block 類別的程式碼 import greenfoot.; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) Write a description of class

任務二 : 產生 20 個有炸彈的磚塊, 放在隨機的位置編輯 Block 類別的程式碼 import greenfoot.; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) Write a description of class 踩地雷遊戲 高慧君南港高中 開啟專案 MineSweep 任務一 : 產生 30X20 個磚塊編輯 Table 類別的程式碼 import greenfoot.; // (World, Actor, GreenfootImage, Greenfoot and MouseInfo) import java.util.arraylist; Write a description of class MyWorld

More information

用手機直接傳值不透過網頁連接, 來當作搖控器控制家電 ( 電視遙控器 ) 按下按鍵發送同時會回傳值來確定是否有送出 問題 :1. 應該是使用了太多 thread 導致在傳值上有問題 2. 一次按很多次按鈕沒辦法即時反應

用手機直接傳值不透過網頁連接, 來當作搖控器控制家電 ( 電視遙控器 ) 按下按鍵發送同時會回傳值來確定是否有送出 問題 :1. 應該是使用了太多 thread 導致在傳值上有問題 2. 一次按很多次按鈕沒辦法即時反應 專題進度 老師 : 趙啟時老師 學生 : 陳建廷 2013/10/13 用手機直接傳值不透過網頁連接, 來當作搖控器控制家電 ( 電視遙控器 ) 按下按鍵發送同時會回傳值來確定是否有送出 問題 :1. 應該是使用了太多 thread 導致在傳值上有問題 2. 一次按很多次按鈕沒辦法即時反應 程式碼 : package com.example.phone; import java.util.arraylist;

More information

0511-Android程式之GPS應用_專題週記4

0511-Android程式之GPS應用_專題週記4 逢甲大學通訊工程學系專題研究 Android 程式之 GPS 應用 專題週記 0511 學生姓名 陳彥儒 D0035131 廖元譽 D0077791 指導老師 楊豐瑞老師繳交日期 2014.05.11 1 匯入 GoogleMap 1.1 取得授權步驟 目前進度 取得 Google 授權鑰匙 實作程式尚未成功 1.1.1 建立個人的 keystore 1.1.2 由個人的 keystore 查詢 SHA1

More information

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc

Fun Time (1) What happens in memory? 1 i n t i ; 2 s h o r t j ; 3 double k ; 4 char c = a ; 5 i = 3; j = 2; 6 k = i j ; H.-T. Lin (NTU CSIE) Referenc References (Section 5.2) Hsuan-Tien Lin Deptartment of CSIE, NTU OOP Class, March 15-16, 2010 H.-T. Lin (NTU CSIE) References OOP 03/15-16/2010 0 / 22 Fun Time (1) What happens in memory? 1 i n t i ; 2

More information

書面

書面 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 5.4 互動功能畫面 程式碼請參考附件-程式三 在進入互動頁面時 會執行setAllText()依寵物狀態數值來 設定狀態文字與頭像 並且依心情決定是否要不要播放音效 觸摸的區域 由於是自己寫的 view 所以並未透過xml來設置 而是透過Layut.addview()來動態新增

More information

ShareText

ShareText 作者 : 林致宇 日期 :2012/1/23 問題 : 如何分享分享文字資訊給其它的應用程式? 解答 : 有時候我們可能會希望 我們的應用程式的資訊 能夠讓使用者分享出去, 讓使用者能夠將此資訊傳送簡訊給其好友或寄電子郵件的方式寄給其好友, 這份文件將示範如何寫出這樣的應用程式 本文件將產出兩個 App, 第一個 App 是 分享資料的來源, 名為 CopyPaste_Source, 功能非常簡單,

More information

epub83-1

epub83-1 C++Builder 1 C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r C + + B u i l d e r 1.1 1.1.1 1-1 1. 1-1 1 2. 1-1 2 A c c e s s P a r a d o x Visual FoxPro 3. / C / S 2 C + + B u i l d e r / C

More information

RecyclerView and CardVew

RecyclerView and CardVew RecyclerView and CardView 建國科技大學資管系饒瑞佶 2017/10 V1 CardView CardView A CardView is a ViewGroup. Like any other ViewGroup, it can be added to youractivity or Fragment using a layout XML file. To create an

More information

TPM BIOS Infineon TPM Smart TPM Infineon TPM Smart TPM TPM Smart TPM TPM Advanced Mode...8

TPM BIOS Infineon TPM Smart TPM Infineon TPM Smart TPM TPM Smart TPM TPM Advanced Mode...8 Smart TPM Rev. 1001 Smart TPM Ultra TPM Smart TPM TPM...3 1. BIOS... 3 2. Infineon TPM Smart TPM... 4 2.1. Infineon TPM...4 2.2. Smart TPM...4 3. TPM... 5 3.1. Smart TPM TPM...5 3.2. Advanced Mode...8

More information

The golden pins of the PCI card can be oxidized after months or years

The golden pins of the PCI card can be oxidized after months or years Q. 如何在 LabWindows/CVI 編譯 DAQ Card 程式? A: 請參考至下列步驟 : 步驟 1: 安裝驅動程式 1. 安裝 UniDAQ 驅動程式 UniDAQ 驅動程式下載位置 : CD:\NAPDOS\PCI\UniDAQ\DLL\Driver\ ftp://ftp.icpdas.com/pub/cd/iocard/pci/napdos/pci/unidaq/dll/driver/

More information

建模与图形思考

建模与图形思考 F06_c 观摩 :ContentProvider 基於軟硬整合觀點 架构與 DB 引擎移植方法 ( c) By 高煥堂 4 通用性基类 ContentProvider 基於軟硬整合觀點 的使用范例 刚才的范例里, 我们直接使用 DataPersist 类的接口来与 SQLite 沟通 本节将替 DataPersist 配上 ContentProvider 基类, 让 Client 能透过 ContentProvider

More information

Microsoft Word - 02.目錄.doc

Microsoft Word - 02.目錄.doc 目錄 -1- 目錄 序 準備篇 一 使用說明... 0-2 二 標示說明... 0-6 三 注意事項... 0-7 第一類 Android 基礎知識 -UI 設計及語法應用 101. 整存整付計算機... 1-2 102. 電費計算機... 1-8 103. 點餐系統... 1-18 104. 計算 BMI 值... 1-23 105. MENU 功能選單... 1-36 106. 畫廊展示...

More information

untitled

untitled JavaEE+Android - 6 1.5-2 JavaEE web MIS OA ERP BOSS Android Android Google Map office HTML CSS,java Android + SQL Sever JavaWeb JavaScript/AJAX jquery Java Oracle SSH SSH EJB+JBOSS Android + 1. 2. IDE

More information

Android + NFC

Android + NFC Android + NFC 建國科技大學資管系饒瑞佶 2017/3 v1 讀取 Tag UUID Android 2.3.3 (API Level 10) 才有支援完整的 NFC 功能 只要 NFC 相容都讀的到 (NFC 或 Mifare) 建立新專案修改 AndroidManifest.xml 加入 , 如果有 NFC Tag 進入感測範圍, 本 App 也會變成可處理的

More information

幻灯片 1

幻灯片 1 Delivering accurate maps to Chinese Android users 为中国安卓用户提供准确的地图服务 Work at Mapbox includes: Android apps, demos, starter kits, documentation, support, syncing Android team with other departments, etc.

More information

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile..

WebSphere Studio Application Developer IBM Portal Toolkit... 2/21 1. WebSphere Portal Portal WebSphere Application Server stopserver.bat -configfile.. WebSphere Studio Application Developer IBM Portal Toolkit... 1/21 WebSphere Studio Application Developer IBM Portal Toolkit Portlet Doug Phillips (dougep@us.ibm.com),, IBM Developer Technical Support Center

More information

untitled

untitled Ogre Rendering System http://antsam.blogone.net AntsamCGD@hotmail.com geometry systemmaterial systemshader systemrendering system API API DirectX OpenGL API Pipeline Abstraction API Pipeline Pipeline configurationpipeline

More information

Microsoft Word - ASM SDK 說明文件

Microsoft Word - ASM SDK 說明文件 System Monitor SDK (for Android) 開發者指南說明書 1. 技術項目簡介 經由簡化的應用程式介面 (Application Programming Interface), 可 提供給 Android 應用程式開發者開發基於 System monitor 的應用程式 2. 應用範圍說明 本技術可應用於具備 Android 系統 2.3.3 以上版本的 Android 嵌入式裝

More information

Android Android Android SDK iv

Android Android Android SDK iv Android Market Google Android SDK Apple Google Microsoft b2c b 2010 Internet Android how why iii Android 240... Android Android SDK iv Android Market Google Android SDK Visual C++ Java N-tier J2EE Unix/Linux

More information

Microsoft Word - template.doc

Microsoft Word - template.doc HGC efax Service User Guide I. Getting Started Page 1 II. Fax Forward Page 2 4 III. Web Viewing Page 5 7 IV. General Management Page 8 12 V. Help Desk Page 13 VI. Logout Page 13 Page 0 I. Getting Started

More information

Windows XP

Windows XP Windows XP What is Windows XP Windows is an Operating System An Operating System is the program that controls the hardware of your computer, and gives you an interface that allows you and other programs

More information

EJB-Programming-3.PDF

EJB-Programming-3.PDF :, JBuilder EJB 2.x CMP EJB Relationships JBuilder EJB Test Client EJB EJB Seminar CMP Entity Beans Value Object Design Pattern J2EE Design Patterns Value Object Value Object Factory J2EE EJB Test Client

More information

<4D6963726F736F667420576F7264202D20BBF9D3DA416E64726F6964C6BDCCA8B5C4B5E7D7D3C5C4C2F4CFB5CDB32E646F63>

<4D6963726F736F667420576F7264202D20BBF9D3DA416E64726F6964C6BDCCA8B5C4B5E7D7D3C5C4C2F4CFB5CDB32E646F63> 基 于 Android 平 台 的 电 子 拍 卖 系 统 摘 要 本 电 子 拍 卖 系 统 其 实 就 是 一 个 电 子 商 务 平 台, 只 要 将 该 系 统 部 署 到 互 联 网 上, 客 户 都 可 以 在 该 系 统 上 发 布 想 出 售 的 商 品, 也 可 以 对 拍 卖 中 的 商 品 参 与 竞 价 整 个 过 程 无 须 人 工 干 预, 由 系 统 自 动 完 成 本

More information

预览图 : (2) 在 SelectCity.java 中增加控件, 用于绑定 select_city 文件的 ListView, TextView,EditTest 等控件 代码和注释如下 :

预览图 : (2) 在 SelectCity.java 中增加控件, 用于绑定 select_city 文件的 ListView, TextView,EditTest 等控件 代码和注释如下 : EditText 实现城市搜索 1801210778 邹宇航 摘要 : 使用 EditText 实现搜索城市的功能, 以此为依据更新 ListView 1. 效果图 : 2. 主要步骤 (1) 在 select-city.xml 布局文件中中添加 EditText 控件用作搜索框, 然后添加 ListView 控件用来显示城市名字内容 代码如下 : 预览图 : (2) 在 SelectCity.java

More information

Microsoft Word - 第1章 Android基本概念.docx

Microsoft Word - 第1章 Android基本概念.docx Android 系 统 下 Java 编 程 详 解 作 者 : 华 清 远 见 第 1 章 Android 基 本 概 念 本 章 简 介 本 章 主 要 介 绍 Android 基 本 概 念 方 面 的 内 容, 包 括 Android 平 台 特 性 Android 系 统 架 构 Android 开 发 框 架 和 Android 开 发 环 境 搭 建 1.1 Android 简 介 Android

More information

Microsoft PowerPoint - Lab 2-3 Android Google Maps.ppt [相容模式]

Microsoft PowerPoint - Lab 2-3 Android Google Maps.ppt [相容模式] 車輛定位與電子地圖整合服務 定位與 Google Maps Network Optimization Lab Department of Computer Science National Chiao Tung University 1 定位與 Google Maps Lab 簡介 : 路徑軌跡記錄程式 Google Maps 程式技巧 取得目前位置經緯度 建立 Google Maps 標示目前位置

More information

基于ECO的UML模型驱动的数据库应用开发1.doc

基于ECO的UML模型驱动的数据库应用开发1.doc ECO UML () Object RDBMS Mapping.Net Framework Java C# RAD DataSetOleDbConnection DataGrod RAD Client/Server RAD RAD DataReader["Spell"].ToString() AObj.XXX bug sql UML OR Mapping RAD Lazy load round trip

More information

Microsoft Word - 01.DOC

Microsoft Word - 01.DOC 第 1 章 JavaScript 简 介 JavaScript 是 NetScape 公 司 为 Navigator 浏 览 器 开 发 的, 是 写 在 HTML 文 件 中 的 一 种 脚 本 语 言, 能 实 现 网 页 内 容 的 交 互 显 示 当 用 户 在 客 户 端 显 示 该 网 页 时, 浏 览 器 就 会 执 行 JavaScript 程 序, 用 户 通 过 交 互 式 的

More information

AL-M200 Series

AL-M200 Series NPD4754-00 TC ( ) Windows 7 1. [Start ( )] [Control Panel ()] [Network and Internet ( )] 2. [Network and Sharing Center ( )] 3. [Change adapter settings ( )] 4. 3 Windows XP 1. [Start ( )] [Control Panel

More information

詞 彙 表 編 號 詞 彙 描 述 1 預 約 人 資 料 中 文 姓 名 英 文 姓 名 身 份 證 字 號 預 約 人 電 話 性 別 2 付 款 資 料 信 用 卡 別 信 用 卡 號 信 用 卡 有 效 日 期 3 住 房 條 件 入 住 日 期 退 房 日 期 人 數 房 間 數 量 入

詞 彙 表 編 號 詞 彙 描 述 1 預 約 人 資 料 中 文 姓 名 英 文 姓 名 身 份 證 字 號 預 約 人 電 話 性 別 2 付 款 資 料 信 用 卡 別 信 用 卡 號 信 用 卡 有 效 日 期 3 住 房 條 件 入 住 日 期 退 房 日 期 人 數 房 間 數 量 入 100 年 特 種 考 試 地 方 政 府 公 務 人 員 考 試 試 題 等 別 : 三 等 考 試 類 科 : 資 訊 處 理 科 目 : 系 統 分 析 與 設 計 一 請 參 考 下 列 旅 館 管 理 系 統 的 使 用 案 例 圖 (Use Case Diagram) 撰 寫 預 約 房 間 的 使 用 案 例 規 格 書 (Use Case Specification), 繪 出 入

More information

建立Android新專案

建立Android新專案 Android 智 慧 型 手 機 程 式 設 計 Android WebService 建 國 科 技 大 學 資 管 系 饒 瑞 佶 2012/4 V1 2012/8 V2 2013/5 V3 2014/10 v4 提 醒 這 節 的 內 容 針 對 的 是 MS 的 Web Service 或 是 使 用 SOAP(Simple Object Access Protocol) 標 準 建 立

More information

Android 开发教程

Android 开发教程 封面 1 文件存取编程基础 文件 文件可以用来存储比使用引用更大数量的数据 Android 提供方法来读 写文件 只有本地文件可以被访问 优点 : 可以存储大容量的数据 缺点 : 文件更新或是格式改变可能会导致巨大的编程工作 文件操作 读文件 Context.openFileInput(String name) 打开一个与应用程序联系的私有文件输入流 当文件不存在时抛出 FileNotFoundException

More information

EJB-Programming-4-cn.doc

EJB-Programming-4-cn.doc EJB (4) : (Entity Bean Value Object ) JBuilder EJB 2.x CMP EJB Relationships JBuilder EJB Test Client EJB EJB Seminar CMP Entity Beans Session Bean J2EE Session Façade Design Pattern Session Bean Session

More information

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM

6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM CHAPTER 6 SQL SQL SQL 6-1 Table Column Data Type Row Record 1. DBMS 2. DBMS MySQL Microsoft Access SQL Server Oracle 3. ODBC SQL 1. Structured Query Language 2. IBM 3. 1986 10 ANSI SQL ANSI X3. 135-1986

More information

Microsoft Word - 第3章.doc

Microsoft Word - 第3章.doc 第 3 章 多个用户界面的程序设计 3.1 页面的切换与传递参数值 3.1.1 传递参数组件 Intent Intent 是 Android 系统的一种运行时的绑定机制, 在应用程序运行时连接两个不同组件 在 Android 的应用程序中不管是页面切换还是传递数据或是调用外部程序都可能要用到 Intent Intent 负责对应用中某次操作的动作 动作涉及的数据 附加数据进行描述, Android

More information

概述

概述 OPC Version 1.6 build 0910 KOSRDK Knight OPC Server Rapid Development Toolkits Knight Workgroup, eehoo Technology 2002-9 OPC 1...4 2 API...5 2.1...5 2.2...5 2.2.1 KOS_Init...5 2.2.2 KOS_InitB...5 2.2.3

More information

1.ai

1.ai HDMI camera ARTRAY CO,. LTD Introduction Thank you for purchasing the ARTCAM HDMI camera series. This manual shows the direction how to use the viewer software. Please refer other instructions or contact

More information

K7VT2_QIG_v3

K7VT2_QIG_v3 ............ 1 2 3 4 5 [R] : Enter Raid setup utility 6 Press[A]keytocreateRAID RAID Type: JBOD RAID 0 RAID 1: 2 7 RAID 0 Auto Create Manual Create: 2 RAID 0 Block Size: 16K 32K

More information

RunPC2_.doc

RunPC2_.doc PowerBuilder 8 (5) PowerBuilder Client/Server Jaguar Server Jaguar Server Connection Cache Thin Client Internet Connection Pooling EAServer Connection Cache Connection Cache Connection Cache Connection

More information

基于UML建模的管理管理信息系统项目案例导航——VB篇

基于UML建模的管理管理信息系统项目案例导航——VB篇 PowerBuilder 8.0 PowerBuilder 8.0 12 PowerBuilder 8.0 PowerScript PowerBuilder CIP PowerBuilder 8.0 /. 2004 21 ISBN 7-03-014600-X.P.. -,PowerBuilder 8.0 - -.TP311.56 CIP 2004 117494 / / 16 100717 http://www.sciencep.com

More information

Microsoft Word zw

Microsoft Word zw 第 1 章 Android 概述 学习目标 : Android Android Android Studio Android Android APK 1.1 1. 智能手机的定义 Smartphone 2. 智能手机的发展 1973 4 3 PC IBM 1994 IBM Simon PDA PDA Zaurus OS 1996 Nokia 9000 Communicator Nokia 9000

More information

ltu

ltu 資 訊 管 理 系 學 齡 前 自 主 學 習 之 行 動 裝 置 輔 助 系 統 指 導 教 授 : 李 靜 怡 教 授 組 員 名 單 : 蔡 承 育 988C012 黃 佳 誼 988C026 鄭 亦 琦 988C060 廖 曼 伶 988C108 中 華 民 國 1 0 2 年 5 月 嶺 東 科 技 大 學 資 訊 管 理 系 學 齡 前 自 主 學 習 之 行 動 裝 置 輔 助 系 統

More information

Android 编程基础 Android 开发教程 & 笔记 1

Android 编程基础 Android 开发教程 & 笔记 1 Android 开发教程 & 笔记 1 多式样 ProgressBar 撰写 : 地狱怒兽 联系 :zyf19870302@126.com 普通圆形 ProgressBar 该类型进度条也就是一个表示运转的过程, 例如发送短信, 连接网络等等, 表示一个过程正 在执行中 一般只要在 XML 布局中定义就可以了

More information

Guide to Install SATA Hard Disks

Guide to Install SATA Hard Disks SATA RAID 1. SATA. 2 1.1 SATA. 2 1.2 SATA 2 2. RAID (RAID 0 / RAID 1 / JBOD).. 4 2.1 RAID. 4 2.2 RAID 5 2.3 RAID 0 6 2.4 RAID 1.. 10 2.5 JBOD.. 16 3. Windows 2000 / Windows XP 20 1. SATA 1.1 SATA Serial

More information

mvc

mvc Build an application Tutor : Michael Pan Application Source codes - - Frameworks Xib files - - Resources - ( ) info.plist - UIKit Framework UIApplication Event status bar, icon... delegation [UIApplication

More information

59 1 CSpace 2 CSpace CSpace URL CSpace 1 CSpace URL 2 Lucene 3 ID 4 ID Web 1. 2 CSpace LireSolr 3 LireSolr 3 Web LireSolr ID

59 1 CSpace 2 CSpace CSpace URL CSpace 1 CSpace URL 2 Lucene 3 ID 4 ID Web 1. 2 CSpace LireSolr 3 LireSolr 3 Web LireSolr ID 58 2016. 14 * LireSolr LireSolr CEDD Ajax CSpace LireSolr CEDD Abstract In order to offer better image support services it is necessary to extend the image retrieval function of our institutional repository.

More information

教育部補助資訊軟體人才培育先導計畫 100 年度課程發展專案計畫 實驗課程名稱 : IPC(Inter-Process Communication) 開發教師 : 張晉源老師 開發學生 : 林政揚 學校系所 : 樹德科技大學資訊工程學系

教育部補助資訊軟體人才培育先導計畫 100 年度課程發展專案計畫 實驗課程名稱 : IPC(Inter-Process Communication) 開發教師 : 張晉源老師 開發學生 : 林政揚 學校系所 : 樹德科技大學資訊工程學系 教育部補助資訊軟體人才培育先導計畫 100 年度課程發展專案計畫 實驗課程名稱 : IPC(Inter-Process Communication) 開發教師 : 張晉源老師 開發學生 : 林政揚 (s11639104@stu.edu.tw) 學校系所 : 樹德科技大學資訊工程學系 實驗目的 本實驗的目的在於讓同學們可以了解 Android 系統核心內部的行程通訊的原理, 透過呼叫系統提供的其中一樣服務

More information

封面-12

封面-12 第十二章 701Client TECHNOLOGY CO.,LTD. 701Client 701Server 701Client "701Client", 12-1 :supervisor :supervisor : 1. : 00~99 100 2. : 00~63 ( 63 / / ) 3. : 18 9 4. : 18 9 5. 12-2 TECHNOLOGY CO.,LTD. 701Client

More information

CC213

CC213 : (Ken-Yi Lee), E-mail: feis.tw@gmail.com 49 [P.51] C/C++ [P.52] [P.53] [P.55] (int) [P.57] (float/double) [P.58] printf scanf [P.59] [P.61] ( / ) [P.62] (char) [P.65] : +-*/% [P.67] : = [P.68] : ,

More information

Lorem ipsum dolor sit amet, consectetuer adipiscing elit

Lorem ipsum dolor sit amet, consectetuer adipiscing elit English for Study in Australia 留 学 澳 洲 英 语 讲 座 Lesson 3: Make yourself at home 第 三 课 : 宾 至 如 归 L1 Male: 各 位 朋 友 好, 欢 迎 您 收 听 留 学 澳 洲 英 语 讲 座 节 目, 我 是 澳 大 利 亚 澳 洲 广 播 电 台 的 节 目 主 持 人 陈 昊 L1 Female: 各 位

More information

1.JasperReport ireport JasperReport ireport JDK JDK JDK JDK ant ant...6

1.JasperReport ireport JasperReport ireport JDK JDK JDK JDK ant ant...6 www.brainysoft.net 1.JasperReport ireport...4 1.1 JasperReport...4 1.2 ireport...4 2....4 2.1 JDK...4 2.1.1 JDK...4 2.1.2 JDK...5 2.1.3 JDK...5 2.2 ant...6 2.2.1 ant...6 2.2.2 ant...6 2.3 JasperReport...7

More information

PPBSalesDB.doc

PPBSalesDB.doc Pocket PowerBuilder SalesDB Pocket PowerBuilder PDA Pocket PowerBuilder Mobile Solution Pocket PowerBuilder Pocket PowerBuilder C:\Program Files\Sybase\Pocket PowerBuilder 1.0 %PPB% ASA 8.0.2 ASA 9 ASA

More information

图 6-1 主界面 MainActivity 界面对应的布局文件 (activity_main.xml) 如下所示 : <?xml version="1.0" encoding="utf-8"?> <RelativeLayout xmlns:android="

图 6-1 主界面 MainActivity 界面对应的布局文件 (activity_main.xml) 如下所示 : <?xml version=1.0 encoding=utf-8?> <RelativeLayout xmlns:android= 第 6 章广播接收者 应用案例 案例 6-1 CallRecord( 通话记录 ) 一 案例描述 1 考核知识点 030006001: 广播接收者简介 030006002: 广播接收者的创建 2 练习目标 广播的静态注册和使用 使用广播处理处理事件 3 需求分析手机最重要的功能就是通话功能, 同样储存通话记录也是必不可少的 该案例使用广 播接收者自己实现通话记录的功能 包括呼出电话 已接来电 未接来电以及通话产生的

More information

Oracle 4

Oracle 4 Oracle 4 01 04 Oracle 07 Oracle Oracle Instance Oracle Instance Oracle Instance Oracle Database Oracle Database Instance Parameter File Pfile Instance Instance Instance Instance Oracle Instance System

More information

建立Android新專案

建立Android新專案 Android 智慧型手機程式設計 程式設計與應用班 Android 資料庫處理 建國科技大學資管系饒瑞佶 2012/4 V1 2012/8 V2 Android 資料庫 -SQLite 資料庫 SQLite 檔案式資料庫 適合嵌入式系統, 不需要額外安裝系統 OPEN SOURCE 資料庫 SQL 指令與一般 DBMS 大同小異, 但有些微差異 SQLite Android 結構 1 資料 結構

More information

Microsoft Word - ch04三校.doc

Microsoft Word - ch04三校.doc 4-1 4-1-1 (Object) (State) (Behavior) ( ) ( ) ( method) ( properties) ( functions) 4-2 4-1-2 (Message) ( ) ( ) ( ) A B A ( ) ( ) ( YourCar) ( changegear) ( lowergear) 4-1-3 (Class) (Blueprint) 4-3 changegear

More information

TX-NR3030_BAS_Cs_ indd

TX-NR3030_BAS_Cs_ indd TX-NR3030 http://www.onkyo.com/manual/txnr3030/adv/cs.html Cs 1 2 3 Speaker Cable 2 HDMI OUT HDMI IN HDMI OUT HDMI OUT HDMI OUT HDMI OUT 1 DIGITAL OPTICAL OUT AUDIO OUT TV 3 1 5 4 6 1 2 3 3 2 2 4 3 2 5

More information

2/80 2

2/80 2 2/80 2 3/80 3 DSP2400 is a high performance Digital Signal Processor (DSP) designed and developed by author s laboratory. It is designed for multimedia and wireless application. To develop application

More information

SDK 概要 使用 Maven 的用户可以从 Maven 库中搜索 "odps-sdk" 获取不同版本的 Java SDK: 包名 odps-sdk-core odps-sdk-commons odps-sdk-udf odps-sdk-mapred odps-sdk-graph 描述 ODPS 基

SDK 概要 使用 Maven 的用户可以从 Maven 库中搜索 odps-sdk 获取不同版本的 Java SDK: 包名 odps-sdk-core odps-sdk-commons odps-sdk-udf odps-sdk-mapred odps-sdk-graph 描述 ODPS 基 开放数据处理服务 ODPS SDK SDK 概要 使用 Maven 的用户可以从 Maven 库中搜索 "odps-sdk" 获取不同版本的 Java SDK: 包名 odps-sdk-core odps-sdk-commons odps-sdk-udf odps-sdk-mapred odps-sdk-graph 描述 ODPS 基础功能的主体接口, 搜索关键词 "odpssdk-core" 一些

More information

目 錄 壹 青 輔 會 結 案 附 件 貳 活 動 計 劃 書 參 執 行 內 容 一 教 學 內 容 二 與 當 地 教 師 教 學 交 流 三 服 務 執 行 進 度 肆 執 行 成 效 一 教 學 課 程 二 與 當 地 教 師 教 學 交 流 三 服 務 滿 意 度 調 查 伍 服 務 檢

目 錄 壹 青 輔 會 結 案 附 件 貳 活 動 計 劃 書 參 執 行 內 容 一 教 學 內 容 二 與 當 地 教 師 教 學 交 流 三 服 務 執 行 進 度 肆 執 行 成 效 一 教 學 課 程 二 與 當 地 教 師 教 學 交 流 三 服 務 滿 意 度 調 查 伍 服 務 檢 2 0 1 0 年 靜 宜 青 年 國 際 志 工 泰 北 服 務 成 果 報 告 指 導 單 位 : 行 政 院 青 年 輔 導 委 員 會 僑 務 委 員 會 主 辦 單 位 : 靜 宜 大 學 服 務 學 習 發 展 中 心 協 力 單 位 : 靜 宜 大 學 師 資 培 育 中 心 財 團 法 人 台 灣 明 愛 文 教 基 金 會 中 華 民 國 九 十 九 年 九 月 二 十 四 日 目

More information

Cadence SPB 15.2 VOICE Cadence SPB 15.2 PC Cadence 3 (1) CD1 1of 2 (2) CD2 2of 2 (3) CD3 Concept HDL 1of 1

Cadence SPB 15.2 VOICE Cadence SPB 15.2 PC Cadence 3 (1) CD1 1of 2 (2) CD2 2of 2 (3) CD3 Concept HDL 1of 1 Cadence SPB 15.2 VOICE 2005-05-07 Cadence SPB 15.2 PC Cadence 3 (1) CD1 1of 2 (2) CD2 2of 2 (3) CD3 Concept HDL 1of 1 1 1.1 Cadence SPB 15.2 2 Microsoft 1.1.1 Windows 2000 1.1.2 Windows XP Pro Windows

More information

Microsoft Word - 11月電子報1130.doc

Microsoft Word - 11月電子報1130.doc 發 行 人 : 楊 進 成 出 刊 日 期 2008 年 12 月 1 日, 第 38 期 第 1 頁 / 共 16 頁 封 面 圖 話 來 來 來, 來 葳 格 ; 玩 玩 玩, 玩 數 學 在 11 月 17 到 21 日 這 5 天 裡 每 天 一 個 題 目, 孩 子 們 依 據 不 同 年 段, 尋 找 屬 於 自 己 的 解 答, 這 些 數 學 題 目 和 校 園 情 境 緊 緊 結

More information

<4D6963726F736F667420576F7264202D2032303130C4EAC0EDB9A4C0E04142BCB6D4C4B6C1C5D0B6CFC0FDCCE2BEABD1A15F325F2E646F63>

<4D6963726F736F667420576F7264202D2032303130C4EAC0EDB9A4C0E04142BCB6D4C4B6C1C5D0B6CFC0FDCCE2BEABD1A15F325F2E646F63> 2010 年 理 工 类 AB 级 阅 读 判 断 例 题 精 选 (2) Computer mouse How does the mouse work? We have to start at the bottom, so think upside down for now. It all starts with mouse ball. As the mouse ball in the bottom

More information

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO

Important Notice SUNPLUS TECHNOLOGY CO. reserves the right to change this documentation without prior notice. Information provided by SUNPLUS TECHNOLO Car DVD New GUI IR Flow User Manual V0.1 Jan 25, 2008 19, Innovation First Road Science Park Hsin-Chu Taiwan 300 R.O.C. Tel: 886-3-578-6005 Fax: 886-3-578-4418 Web: www.sunplus.com Important Notice SUNPLUS

More information

<ADB6ADB1C25EA8FAA6DB2D4D56432E706466>

<ADB6ADB1C25EA8FAA6DB2D4D56432E706466> packages 3-31 PART 3-31 03-03 ASP.NET ASP.N MVC ASP.NET ASP.N MVC 4 ASP.NET ASP.NE MVC Entity Entity Framework Code First 2 TIPS Visual Studio 20NuGetEntity NuGetEntity Framework5.0 CHAPTER 03 59 3-3-1

More information

INTRODUCTION TO COM.DOC

INTRODUCTION TO COM.DOC How About COM & ActiveX Control With Visual C++ 6.0 Author: Curtis CHOU mahler@ms16.hinet.net This document can be freely release and distribute without modify. ACTIVEX CONTROLS... 3 ACTIVEX... 3 MFC ACTIVEX

More information

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp

Spyder Anaconda Spyder Python Spyder Python Spyder Spyder Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Sp 01 1.6 Spyder Anaconda Spyder Python Spyder Python Spyder Spyder 1.6.1 Spyder 開始 \ 所有程式 \ Anaconda3 (64-bit) \ Spyder Spyder IPython Python IPython Spyder Python File

More information

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10

1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 Java V1.0.1 2007 4 10 1 4 1.1 4 1.2..4 2..4 2.1..4 3.4 3.1 Java.5 3.1.1..5 3.1.2 5 3.1.3 6 4.6 4.1 6 4.2.6 5 7 5.1..8 5.1.1 8 5.1.2..8 5.1.3..8 5.1.4..9 5.2..9 6.10 6.1.10 6.2.10 6.3..10 6.4 11 7.12 7.1

More information

Microsoft Office SharePoint Server MOSS Web SharePoint Web SharePoint 22 Web SharePoint Web Web SharePoint Web Web f Lists.asmx Web Web CAML f

Microsoft Office SharePoint Server MOSS Web SharePoint Web SharePoint 22 Web SharePoint Web Web SharePoint Web Web f Lists.asmx Web Web CAML f Web Chapter 22 SharePoint Web Microsoft Office SharePoint Server MOSS Web SharePoint Web SharePoint 22 Web 21 22-1 SharePoint Web Web SharePoint Web Web f Lists.asmx Web Web CAML f Views.asmx View SharePoint

More information

Microsoft PowerPoint - L17_Inheritance_v4.pptx

Microsoft PowerPoint - L17_Inheritance_v4.pptx C++ Programming Lecture 17 Wei Liu ( 刘 威 ) Dept. of Electronics and Information Eng. Huazhong University of Science and Technology May. 2015 Lecture 17 Chapter 20. Object-Oriented Programming: Inheritance

More information

27 :OPC 45 [4] (Automation Interface Standard), (Costom Interface Standard), OPC 2,,, VB Delphi OPC, OPC C++, OPC OPC OPC, [1] 1 OPC 1.1 OPC OPC(OLE f

27 :OPC 45 [4] (Automation Interface Standard), (Costom Interface Standard), OPC 2,,, VB Delphi OPC, OPC C++, OPC OPC OPC, [1] 1 OPC 1.1 OPC OPC(OLE f 27 1 Vol.27 No.1 CEMENTED CARBIDE 2010 2 Feb.2010!"!!!!"!!!!"!" doi:10.3969/j.issn.1003-7292.2010.01.011 OPC 1 1 2 1 (1., 412008; 2., 518052), OPC, WinCC VB,,, OPC ; ;VB ;WinCC Application of OPC Technology

More information

Chapter 9: Objects and Classes

Chapter 9: Objects and Classes Fortran Algol Pascal Modula-2 BCPL C Simula SmallTalk C++ Ada Java C# C Fortran 5.1 message A B 5.2 1 class Vehicle subclass Car object mycar public class Vehicle extends Object{ public int WheelNum

More information

untitled

untitled 1 Outline 數 料 數 數 列 亂數 練 數 數 數 來 數 數 來 數 料 利 料 來 數 A-Z a-z _ () 不 數 0-9 數 不 數 SCHOOL School school 數 讀 school_name schoolname 易 不 C# my name 7_eleven B&Q new C# (1) public protected private params override

More information

Chapter 9: Objects and Classes

Chapter 9: Objects and Classes Java application Java main applet Web applet Runnable Thread CPU Thread 1 Thread 2 Thread 3 CUP Thread 1 Thread 2 Thread 3 ,,. (new) Thread (runnable) start( ) CPU (running) run ( ) blocked CPU sleep(

More information

目 錄 版 次 變 更 記 錄... 2 原 始 程 式 碼 類 型 之 使 用 手 冊... 3 一 安 裝 軟 體 套 件 事 前 準 備... 3 二 編 譯 流 程 說 明... 25 1

目 錄 版 次 變 更 記 錄... 2 原 始 程 式 碼 類 型 之 使 用 手 冊... 3 一 安 裝 軟 體 套 件 事 前 準 備... 3 二 編 譯 流 程 說 明... 25 1 科 技 部 自 由 軟 體 專 案 原 始 程 式 碼 使 用 手 冊 Source Code Manual of NSC Open Source Project 可 信 賴 的 App 安 全 應 用 框 架 -App 應 用 服 務 可 移 轉 性 驗 證 Trusted App Framework -Transferability Verification on App MOST 102-2218-E-011-012

More information

untitled

untitled ArcGIS Server Web services Web services Application Web services Web Catalog ArcGIS Server Web services 6-2 Web services? Internet (SOAP) :, : Credit card authentication, shopping carts GIS:, locator services,

More information

第六章

第六章 Reflection and Serving Learning 長 庚 科 技 大 學 護 理 系 劉 杏 元 一 服 務 學 習 為 何 要 反 思 All those things that we had to do for the service-learning, each one, successively helped me pull together what I d learned.

More information

ebook140-9

ebook140-9 9 VPN VPN Novell BorderManager Windows NT PPTP V P N L A V P N V N P I n t e r n e t V P N 9.1 V P N Windows 98 Windows PPTP VPN Novell BorderManager T M I P s e c Wi n d o w s I n t e r n e t I S P I

More information

使用手冊

使用手冊 使用手冊 版權所有 2013 年 Microtek International, Inc. 保留所有權利 商標 Microtek MII MiiNDT ScanWizard Microtek International, Inc. Windows Microsoft Corporation 重要須知 Microtek Microtek Windows Microsoft Windows I49-004528

More information

投影片 1

投影片 1 Chapter 11 Google 服務應用開發 Google 服務應用開發 Google 提供了許多免費服務, 例如搜尋引擎 Google Map Google 翻譯 Google 文件 Google 日曆 GMail Google Talk Youtube 等常見的服務,Google 擁有大量的資料以及對這些資料作分析的能力, 因此可以提供更多元的服務類型 在豐富的資源下將 Google 服務與

More information

untitled

untitled 1 Outline 料 類 說 Tang, Shih-Hsuan 2006/07/26 ~ 2006/09/02 六 PM 7:00 ~ 9:30 聯 ives.net@gmail.com www.csie.ntu.edu.tw/~r93057/aspnet134 度 C# 力 度 C# Web SQL 料 DataGrid DataList 參 ASP.NET 1.0 C# 例 ASP.NET 立

More information

建模与图形思考

建模与图形思考 C03_c 基 於 軟 硬 整 合 觀 點 JNI: 从 C 调 用 Java 函 数 ( c) By 高 煥 堂 3 How-to: 基 於 軟 硬 整 合 觀 點 从 C 调 用 Java 函 数 如 果 控 制 点 摆 在 本 地 C 层, 就 会 常 常 1. 从 本 地 C 函 数 去 调 用 Java 函 数 ; 2. 从 本 地 C 函 数 去 存 取 Java 层 对 象 的 属 性

More information

PowerPoint 簡報

PowerPoint 簡報 UI 設計 Android 專案目錄架構 Android 專案建立後會自動產生 3 個主要目錄 src:java 程式檔案 res: 資源 ( 文字 圖形 聲音檔案等 ) 與 UI 設定有關的 layout 檔 此目錄內檔案名稱只能為小寫字母 數字 _. gen:r.java 根據 res 目錄內容自動產生 不要去修改 R.java Android 中所有的資源檔案 ( 圖片 XML 等 ) 命名都必須使用英文小寫,

More information

前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii

前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii 前言 C# C# C# C C# C# C# C# C# microservices C# More Effective C# More Effective C# C# C# C# Effective C# 50 C# C# 7 Effective vii C# 7 More Effective C# C# C# C# C# C# Common Language Runtime CLR just-in-time

More information

1-1 database columnrow record field 不 DBMS Access Paradox SQL Server Linux MySQL Oracle IBM Informix IBM DB2 Sybase 1-2

1-1 database columnrow record field 不 DBMS Access Paradox SQL Server Linux MySQL Oracle IBM Informix IBM DB2 Sybase 1-2 CHAPTER 1 Understanding Core Database Concepts 1-1 database columnrow record field 不 DBMS Access Paradox SQL Server Linux MySQL Oracle IBM Informix IBM DB2 Sybase 1-2 1 Understanding Core Database Concepts

More information