Dear 朝陽的各位
成績出來囉! - [View]
BP
Translate
2011年1月20日 星期四
2011年1月13日 星期四
99-1 朝陽資工 - 手持式裝置程式設計 期末測驗
考題在此:
注意事項:
- 考試時間 100 分鐘
- 請修改目錄名稱為:你的 [學號][姓名] ,例: [D912345][蒙奇D魯夫]
- 請直接在目錄的的檔案編輯操作
- 完成後請直接將該目錄壓縮後上傳繳交,即可離開
- 上傳時相同檔名會取代已有的相同檔案,請同學記得重新整理後檢查上傳時間是否正確
上傳位址:
- [ Link ]
BP:考試加油!
2011年1月8日 星期六
Dear 弘光資工、中台國企、行銷,朝陽資工的同學們
Dear 中台國企、行銷,朝陽資工,弘光資工的同學們
一個學期很快就過去了,
老師期許大家都能有所收獲。
雖然我們只是短短一學期的見面,
但我希望帶給大家的,不僅僅只是書本裡的知識,
還有認識自己、明辨是非與關懷這個社會、環境與文化的刺激。
希望大家能接觸更多不同的人事物,
學著去玩、去體驗、去關懷,
然後找到屬於自己的歸屬,自己的方向,
讓生活、學習不再是漫無目標。
加油! 我們一起努力!
學期的最後,希望大家一起來分享你的想法,
這同時也是大家的加分題,
請別擔心,你的個人資料是不會公開的,
盡管暢所欲言吧。
中台國企、行銷,朝陽資工、弘光資工的同學們,
請填下面這個表單:
https://spreadsheets.google.com/viewform?formkey=dEJHbExQQnFsUVVmZjJocl8xaFBBS2c6MQ
BP 2011.01.08
一個學期很快就過去了,
老師期許大家都能有所收獲。
雖然我們只是短短一學期的見面,
但我希望帶給大家的,不僅僅只是書本裡的知識,
還有認識自己、明辨是非與關懷這個社會、環境與文化的刺激。
希望大家能接觸更多不同的人事物,
學著去玩、去體驗、去關懷,
然後找到屬於自己的歸屬,自己的方向,
讓生活、學習不再是漫無目標。
加油! 我們一起努力!
學期的最後,希望大家一起來分享你的想法,
這同時也是大家的加分題,
請別擔心,你的個人資料是不會公開的,
盡管暢所欲言吧。
中台國企、行銷,朝陽資工、弘光資工的同學們,
請填下面這個表單:
https://spreadsheets.google.com/viewform?formkey=dEJHbExQQnFsUVVmZjJocl8xaFBBS2c6MQ
BP 2011.01.08
2010年12月30日 星期四
99-1朝陽資工 - 手持式裝置程式設計 - 成績表
Dear 朝陽的各位同學
期中與期中加分成績已經出來,
請同學檢查有沒有問題,若有問題請在本文張回覆中敘述並寫上你的學號姓名。
謝謝
成績如下:
https://spreadsheets.google.com/ccc?key=0AsoQevXXmTncdF9aME9DU3A0UzNKaUZhSDZPYzFWckE&hl=zh_TW#gid=1
BP
期中與期中加分成績已經出來,
請同學檢查有沒有問題,若有問題請在本文張回覆中敘述並寫上你的學號姓名。
謝謝
成績如下:
https://spreadsheets.google.com/ccc?key=0AsoQevXXmTncdF9aME9DU3A0UzNKaUZhSDZPYzFWckE&hl=zh_TW#gid=1
BP
99-1朝陽資工 - 手持式裝置程式設計 - Android Service
Android : Service
Detail From :
A Service is an application component representing either an application's desire to perform a longer-running operation while not interacting with the user or to supply functionality for other applications to use. Each service class must have a corresponding
declaration in its package's AndroidManifest.xml. Services can be started with Context.startService() and Context.bindService().- There are two reasons that a service can be run by the system. If someone calls Context.startService() then the system will retrieve the service (creating it and calling its onCreate() method if needed) and then call itsonStart(Intent, int) method with the arguments supplied by the client. The service will at this point continue running until Context.stopService() or stopSelf() is called. Note that multiple calls to Context.startService() do not nest (though they do result in multiple corresponding calls to onStart()), so no matter how many times it is started a service will be stopped once Context.stopService() or stopSelf() is called.
- Clients can also use Context.bindService() to obtain a persistent connection to a service. This likewise creates the service if it is not already running (calling onCreate() while doing so), but does not call onStart(). The client will receive the IBinder object that the service returns from its onBind(Intent) method, allowing the client to then make calls back to the service. The service will remain running as long as the connection is established (whether or not the client retains a reference on the service's IBinder). Usually the IBinder returned is for a complex interface that has beenwritten in aidl.
- A service can be both started and have connections bound to it. In such a case, the system will keep the service running as long as either it is started or there are one or more connections to it with theContext.BIND_AUTO_CREATE flag. Once neither of these situations hold, the service's onDestroy() method is called and the service is effectively terminated. All cleanup (stopping threads, unregistering receivers) should be complete upon returning from onDestroy().
Service運作流程圖: Pic From: Link
額外資訊連結:
範例下載:
2010年12月29日 星期三
99-1朝陽資工 - 手持式裝置程式設計 - Android Thread
Android 的UI運作方式與Java Swing不同,
它使用的是單一Thread運作方式,意思就是UI前端只有一個Thread (ex View),
其餘都在背景執行,而背景執行的thread若要用到前景Thread的事件或方法,
則會產生錯誤事件:CalledFromWrongThreadException
那Android背景事件該如何使用前景呢,
舉例來說若我們啟動了一個Timer,它便會於背景執行,
但若在Timer的 TimerTask中我們想要讓他啟動一個動作(如Toast)
這時若以傳統Java Swing的方式執行是沒問題的,
但若在Android執行,則無法顯示結果,
那該怎麼辦呢?
事實上Android提供了一個類別用來讓背景Thread使用前景的物件,
這個類別便是 Handler ,詳見:Android Handler Doc
接續上述的例子,
我們便可以透過Handler的message 傳送,來達到操作前景Thread的效果囉。
它使用的是單一Thread運作方式,意思就是UI前端只有一個Thread (ex View),
其餘都在背景執行,而背景執行的thread若要用到前景Thread的事件或方法,
則會產生錯誤事件:CalledFromWrongThreadException
那Android背景事件該如何使用前景呢,
舉例來說若我們啟動了一個Timer,它便會於背景執行,
但若在Timer的 TimerTask中我們想要讓他啟動一個動作(如Toast)
這時若以傳統Java Swing的方式執行是沒問題的,
但若在Android執行,則無法顯示結果,
那該怎麼辦呢?
事實上Android提供了一個類別用來讓背景Thread使用前景的物件,
這個類別便是 Handler ,詳見:Android Handler Doc
接續上述的例子,
我們便可以透過Handler的message 傳送,來達到操作前景Thread的效果囉。
BP
final Handler handler = new Handler(){
public void handleMessage(Message msg) {
switch (msg.what) {
case 1:
Toast toast = Toast.makeText(getApplicationContext(), "SHOW)", Toast.LENGTH_SHORT);
toast.show();
break;
}
super.handleMessage(msg);
}
};
timer = new Timer();
TimerTask timerTask = new TimerTask() {
public void run() {
Message message = new Message();
message.what = 1;
handler.sendMessage(message);
}
};
//設定Alarm time,且Time out時會執行timerTask送出信息
timer.schedule(timerTask, 3000, 3000);
2010年12月23日 星期四
99-1朝陽資工 - 手持式裝置程式設計 - 網頁元件
99-1朝陽資工 - 手持式裝置程式設計 - 網頁元件
網頁元件 WebView
網頁元件 WebView
- 介紹 : Link
- Method
- loadUrl()
- setWebViewClient
- zoomIn()
- zoomOut()
- getTitle()
- getUrl()
- 建構與方法範例
- 建立
- WebView webView = (WebView) findViewById(R.id.WebView01)
- 設定連結
- webView.setWebViewClient(new WebViewClient())
- 設定對像
- webView.loadUrl("http://tw.yahoo.com/") .
- 範例檔下載:
- 含:Zoom in , Zoom out, AlertDialog, getTitle, getUrl
- Download
99-1朝陽資工 - 手持式裝置程式設計 - 鍵盤偵測
99-1朝陽資工 - 手持式裝置程式設計 - 鍵盤偵測
鍵盤事件偵測:
鍵盤事件偵測:
- 所屬類別:View
- 介面interface:View.OnKeyListener
- public abstract boolean onKey (View v, int keyCode, KeyEvent event)
- Parameters
- v The view the key has been dispatched to.
- keyCode The code for the physical key that was pressed
- event The KeyEvent object containing full information about the event.
- Returns
- True if the listener has consumed the event, false otherwise.
- 範例
- 建立EditText的Listener
- editText.setOnKeyListener(new OnKeyListener()
- 偵測Key事件
- public boolean onKey(View v, int keyCode, KeyEvent event)
- 取出Key事件
- if (keyCode == KeyEvent.KEYCODE_ENTER)
- 範例下載
2010年12月17日 星期五
弘光朝陽 - 99-1 網路程式設計 - 挑戰題 RSA加密金鑰系統
挑戰題 RSA加密金鑰系統
請同學挑戰寫出RSA加密金鑰系統,
參考資料如下:
請同學挑戰寫出RSA加密金鑰系統,
參考資料如下:
挑戰重點:
- 如何產生質數
- 如何儲存長整數
- 文字編碼的效能
BP
2010年12月16日 星期四
99-1朝陽資工 - 手持式裝置程式設計 - 數值轉換
Android 數值轉換 (JAVA)
- String 轉為 Int : Integer.parseInt( STRING )
- String 轉為 long : Long.parseLong( STRING )
- String 轉為 float: Float.parseFloat( STRING )
- 數值轉String : String.valueOf( 數值 )
- Ex : String.valueOf( INT )
BP
2010年12月15日 星期三
99-1朝陽資工 - 手持式裝置程式設計 - Shared Preferences
Shared Preferences
範例:
練習:
- 資料處理 : Shared Preferences - Detail : Link
- 資料設定 : SharedPreferences.Editor - Detail : Link
- 資料設定方法:
- Ex::
SharedPreferences settings = getSharedPreferences(SETTING_PREF, 0);
settings.edit()
.putString(SHARED_MSG1, mEditText01.getText().toString())
.putInt(SHARED_MSG2, int2)
.putLong(SHARED_MSG3, long3)
.putFloat(SHARED_MSG4, float4)
.putBoolean(SHARED_MSG5, boolean5)
.commit();
- 資料讀取方法
- Ex:
SharedPreferences settings = getSharedPreferences(SETTING_PREF, 0);
String msg1 = settings.getString(SHARED_MSG1, "");
int msg2_int = settings.getInt(SHARED_MSG2, defint2);
long msg3_long = settings.getLong(SHARED_MSG3, deflong3);
float msg4_float = settings.getFloat(SHARED_MSG4, deffloat4);
boolean msg5_boolean = settings.getBoolean(SHARED_MSG5, defboolean5);
範例:
練習:
- 製作SharedPreferences版的MSN-Like程式
- 請加入清空歷史訊息的效果
2010年11月17日 星期三
99-1 朝陽資工 - 手持式裝置程式設計 期中測驗
考題在此:
注意事項:
- 考試時間 100 分鐘
- 請修改目錄名稱為:你的 [學號][姓名] ,例: [D912345][蒙奇D魯夫]
- 請直接在目錄的的檔案編輯操作
- 完成後請直接將該目錄壓縮後上傳繳交,即可離開
- 上傳時相同檔名會取代已有的相同檔案,請同學記得重新整理後檢查上傳時間是否正確
上傳位址:
- [ Link ]
BP:考試加油!
2010年11月12日 星期五
99-1 朝陽資工 - 手持式裝置程式設計 猜數字遊戲
猜數字遊戲
說明
亂數產生一組四個不重複數字,並讓使用者輸入值,最後顯示其輸入的值與設定值的差異。
如:設定1368
- 輸入 1234 顯示 1A1B
- 輸入 1638 顯示 2A2B
- 輸入 1368 顯示 4A0B
製作流程與提示項目
- 建立1個Activity其具有功能如下
- 自動產生亂數
- 輸入數字
- 以歷史訊息方式顯示輸入的數字比較設定數字的結果
- 亂數產生範例
- num = (int)(Math.random() *10 );
2010年11月11日 星期四
99-1 朝陽資工 - 手持式裝置程式設計 Intent Code
以下程式碼僅供片段,請自行補完!
- 使用Intent,並傳出資料
Intent intent1 = new Intent( chattest.this , rece.class );
EditText et = (EditText)findViewById(R.id.edit_msg);
CharSequence cs = et.getText();
intent1.putExtra( "message" , cs);
startActivityForResult(intent1 , 0);
- 取出Intent資料
Bundle ex = getIntent().getExtras();
if ( ex != null)
{
TextView tv = (TextView) findViewById(R.id.txt_msg);
tv.setText( ex.getCharSequence("message"));
}
- 結束子Activity並返回其父Activity
Intent intent = new Intent();
intent.putExtra("msg", text);
setResult(RESULT_OK, intent);
finish();
2010年11月4日 星期四
99-1 朝陽資工 - 手持式裝置程式設計 20111104測驗
BMI Caculator
製作流程與提示項目
○新增Android Project
○製作Layout項目
- 設定Layout方式
- 設定標題TextView並編輯內容
- 設定EditText 以輸入身高體重
- 製作Button做為分析與結束使用
- 設定一個EditText元件做為輸出區域 (預設一開始看不見 Visibility= invisible)
- 製作TextView並設定標題內容,TextView有以下幾個:
- 標題
- BMI值顯示
- 製作一個EditText元件做為結果判斷使用 (預設一開始看不見 Visible = false )
○撰寫分析Button程式
- 建立全域變數 :
- String result ;
- float bmi ;
- 判斷兩個EditText元件是否有輸入值 (使用IF ELSE 判斷式 or 例外)
- 若無,使用 Toast 告知
- 若有,便繼續
- 取得兩個EditText元件中的值並將文字型態轉為Float型態( Float.parseFloat() )
- 計算BMI值,公式如下:
- BMI = 體重 (KG) / 身高 (M^2)
- Hints:
- M為公尺,故輸入為公分必須先除以100
- 打開BMI顯示TextView,並顯示BMI值 (需將Float轉回Str才能輸出)
- 依據BMI值設定輸出於EditText的文字,(使用IF判斷,並以一個string變數儲存):
- bmi < 15 ,Memo顯示:'過於飢餓 Starvation'
- bmi > =15 且 bmi < 18.5,Memo顯示:'體重不足 Underweight'
- bmi >= 18.5 且 bmi < 24 ,Memo顯示:'一般體重 Normal'
- bmi >= 24 且 bmi < 30 ,Memo顯示:'超重 Overweight'
- bmi >= 30 且 bmi < 40 ,Memo顯示:'嚴重超重 Obese'
- bmi >= 40 ,Memo顯示:'極度超重 Morbidly Obese'
- 將String變數設定至Text元件
- 完成! 請找老師登記
2010年10月27日 星期三
99-1朝陽資工 - 手持式裝置程式設計 - Layout
常用Layout包裝方式 ( layout_width, layout_height)
Layout Type
- fill_parent
- wrap_content
Layout Type
- Linear Layout
- orientation
- vertical
- horizontal
- Table Layout
- stretchColumns : 值2為 3*3大小
- shrinkColumns : 指定當填滿時,哪一格要往下挪字
- collapseColumns : 隱藏指定列
- 使用
TableRow 規劃每一行
延伸閱讀:http://ppt.cc/1ROY Exercise - 使用collapseColumns 讓按鈕消失
TableLayout object setColumnCollapsed() 可以控制 collapseColumns
- Relative Layout
- layout_toRightOf
- layout_below
- layout_toLeftOf
- Absolute Layout
- layout_y , layout_x
- px (pixels)像素
- dip (device independent pixels)設備獨立像素
- Android Applications for Multiple Screen Sizes
http://diigo.com/0ddsi - Supporting Multiple Screens | Android Developers http://diigo.com/0ddsg
- Frame Layout
- 最簡單的Layout模式
- layout_gravity指定位址
2010年10月21日 星期四
99-1朝陽資工 - 手持式裝置程式設計 - Code (20101021)
99-1朝陽資工 - 手持式裝置程式設計 - Code (20101021)
同學玩玩看吧:
同學玩玩看吧:
Button btn_inputname = (Button)findViewById( R.id.Button01 );
btn_inputname.setOnClickListener(
new View.OnClickListener() {
public void onClick(View v) {
EditText editText = (EditText)findViewById(R.id.EditText01);
CharSequence text = editText.getText();
name_in = text.toString() ;
}
});
2010年10月14日 星期四
99-1朝陽資工 - 手持式裝置程式設計 - Intent
Android - Intent
An intent is an abstract description of an operation to be performed. It can be used with
startActivity to launch an Activity, broadcastIntent to send it to any interested BroadcastReceiver components, andstartService(Intent) or bindService(Intent, ServiceConnection, int) to communicate with a background Service.An Intent provides a facility for performing late runtime binding between the code in different applications. Its most significant use is in the launching of activities, where it can be thought of as the glue between activities. It is basically a passive data structure holding an abstract description of an action to be performed. The primary pieces of information in an intent are:
- data -- The data to operate on, such as a person record in the contacts database, expressed as a
Uri.
- Detail : http://developer.android.com/reference/android/content/Intent.html
- Standard Activity Actions : http://diigo.com/0d5vt
Chat 小程式:
- 新增專案
- 新增class
- 新增XML於layout
- 新增變數於values
- 修改AndroidManifest.xml
- 新增Application Nodes
- 增加Activity
- 修改新增class
- 撰寫程式
2010年10月13日 星期三
99-1朝陽資工 - 手持式裝置程式設計 - Activity
Android: Activity - Lifecycle
Simple Flowchart : [ link ]
Three loops
- The entire lifetime of an activity happens between the first call to
onCreate(Bundle)through to a single final call toonDestroy(). An activity will do all setup of "global" state in onCreate(), and release all remaining resources in onDestroy(). For example, if it has a thread running in the background to download data from the network, it may create that thread in onCreate() and then stop the thread in onDestroy(). - The visible lifetime of an activity happens between a call to
onStart()until a corresponding call toonStop(). During this time the user can see the activity on-screen, though it may not be in the foreground and interacting with the user. Between these two methods you can maintain resources that are needed to show the activity to the user. For example, you can register aBroadcastReceiverin onStart() to monitor for changes that impact your UI, and unregister it in onStop() when the user an no longer see what you are displaying. The onStart() and onStop() methods can be called multiple times, as the activity becomes visible and hidden to the user. - The foreground lifetime of an activity happens between a call to
onResume()until a corresponding call toonPause(). During this time the activity is in front of all other activities and interacting with the user. An activity can frequently go between the resumed and paused states -- for example when the device goes to sleep, when an activity result is delivered, when a new intent is delivered -- so the code in these methods should be fairly lightweight.
Lifecycle DEMO :
http://blip.tv/file/958450/
Example: LifecycleExample
- Toast Class
- A toast is a view containing a quick little message for the user. The toast class helps you create and show those. When the view is shown to the user, appears as a floating view over the application. It will never receive focus. The user will probably be in the middle of typing something else. The idea is to be as unobtrusive as possible, while still showing the user the information you want them to see. Two examples are the volume control, and the brief message saying that your settings have been saved.
- Detail : [ Link ]
- Activity Class :
- An activity is a single, focused thing that the user can do. Almost all activities interact with the user, so the Activity class takes care of creating a window for you in which you can place your UI with
setContentView(View). While activities are often presented to the user as full-screen windows, they can also be used in other ways: as floating windows (via a theme withwindowIsFloatingset) or embedded inside of another activity (usingActivityGroup). - Detail : [ Link ]
- Activity | Android Developers http://diigo.com/0d5sd
- Starting Activities and Getting Results : http://diigo.com/0d5v6
訂閱:
意見 (Atom)
