- 將Android source code下載回來,參考 http://source.android.com/source/downloading.html
- 在Android sdk的目錄下/platforms/android-10/目錄下,新增一個sources子目錄
- 到下載回來的Android source code裡面,找到
/gingerbread/frameworks/base/core/java/android/ . /gingerbread/frameworks/base/core/java/com/ . /gingerbread/dalvik/libcore/dalvik/src/main/java/dalvik/ . /gingerbread/dalvik/libcore/luni-kernel/src/main/java/java/ . /gingerbread/dalvik/libcore/luni-kernel/src/main/java/org/ .
- 將上面資料複製到sources目錄下
- 完成
2012年2月3日 星期五
在Eclipse中加入android framework的source
以下皆以gingerbread平台(level 10)為例子,其他平台做法相同
2012年1月31日 星期二
Android中Broadcast的action整理
Android平台上,當系統發生某種狀態的改變時(如收到一封簡訊),會發出Broadcast通知,如果其他程式想要在某些狀態發生時做特定處理,就必須註冊接收這些狀態。
底下列出目前所有Android會發出的Broadcast action
Api Level 3:(SDK 1.5)
Api Level 4 (SDK 1.6) 新增
Api Level 5 (SDK 2.0) 修改
Api Level 5 (SDK 2.0) 新增
Api Level 7(SDK 2.1) 新增
Api Level 8(SDK 2.2) 新增
底下列出目前所有Android會發出的Broadcast action
Api Level 3:(SDK 1.5)
- android.bluetooth.a2dp.intent.action.SINK_STATE_CHANGED
- android.bluetooth.intent.action.BLUETOOTH_STATE_CHANGED
- android.bluetooth.intent.action.BOND_STATE_CHANGED_ACTION
- android.bluetooth.intent.action.DISCOVERY_COMPLETED
- android.bluetooth.intent.action.DISCOVERY_STARTED
- android.bluetooth.intent.action.HEADSET_ADUIO_STATE_CHANGED
- android.bluetooth.intent.action.HEADSET_STATE_CHANGED
- android.bluetooth.intent.action.NAME_CHANGED
- android.bluetooth.intent.action.PAIRING_CANCEL
- android.bluetooth.intent.action.PAIRING_REQUEST
- android.bluetooth.intent.action.REMOTE_DEVICE_CONNECTED
- android.bluetooth.intent.action.REMOTE_DEVICE_DISAPPEARED
- android.bluetooth.intent.action.REMOTE_DEVICE_DISAPPEARED
- android.bluetooth.intent.action.REMOTE_DEVICE_DISCONNECTED
- android.bluetooth.intent.action.REMOTE_DEVICE_DISCONNECT_REQUESTED
- android.bluetooth.intent.action.REMOTE_DEVICE_FOUND
- android.bluetooth.intent.action.REMOTE_NAME_FAILED
- android.bluetooth.intent.action.REMOTE_NAME_UPDATED
- android.bluetooth.intent.action.SCAN_MODE_CHANGED
- android.intent.action.AIRPLANE_MODE
- android.intent.action.BATTERY_CHANGED
- android.intent.action.BATTERY_LOW
- android.intent.action.BOOT_COMPLETED
- android.intent.action.CAMERA_BUTTON
- android.intent.action.CONFIGURATION_CHANGED
- android.intent.action.DATA_SMS_RECEIVED
- android.intent.action.DATE_CHANGED
- android.intent.action.DEVICE_STORAGE_LOW
- android.intent.action.DEVICE_STORAGE_OK
- android.intent.action.GTALK_CONNECTED
- android.intent.action.GTALK_DISCONNECTED
- android.intent.action.HEADSET_PLUG
- android.intent.action.INPUT_METHOD_CHANGED
- android.intent.action.MANAGE_PACKAGE_STORAGE
- android.intent.action.MEDIA_BAD_REMOVAL
- android.intent.action.MEDIA_BUTTON
- android.intent.action.MEDIA_CHECKING
- android.intent.action.MEDIA_EJECT
- android.intent.action.MEDIA_MOUNTED
- android.intent.action.MEDIA_NOFS
- android.intent.action.MEDIA_REMOVED
- android.intent.action.MEDIA_SCANNER_FINISHED
- android.intent.action.MEDIA_SCANNER_SCAN_FILE
- android.intent.action.MEDIA_SCANNER_STARTED
- android.intent.action.MEDIA_SHARED
- android.intent.action.MEDIA_UNMOUNTABLE
- android.intent.action.MEDIA_UNMOUNTED
- android.intent.action.NEW_OUTGOING_CALL
- android.intent.action.PACKAGE_ADDED
- android.intent.action.PACKAGE_CHANGED
- android.intent.action.PACKAGE_DATA_CLEARED
- android.intent.action.PACKAGE_INSTALL
- android.intent.action.PACKAGE_REMOVED
- android.intent.action.PACKAGE_REPLACED
- android.intent.action.PACKAGE_RESTARTED
- android.intent.action.PHONE_STATE
- android.intent.action.PROVIDER_CHANGED
- android.intent.action.REBOOT
- android.intent.action.SCREEN_OFF
- android.intent.action.SCREEN_ON
- android.intent.action.TIMEZONE_CHANGED
- android.intent.action.TIME_SET
- android.intent.action.TIME_TICK
- android.intent.action.UID_REMOVED
- android.intent.action.UMS_CONNECTED
- android.intent.action.UMS_DISCONNECTED
- android.intent.action.USER_PRESENT
- android.intent.action.WALLPAPER_CHANGED
- android.media.AUDIO_BECOMING_NOISY
- android.media.RINGER_MODE_CHANGED
- android.media.VIBRATE_SETTING_CHANGED
- android.net.conn.BACKGROUND_DATA_SETTING_CHANGED
- android.net.wifi.NETWORK_IDS_CHANGED
- android.net.wifi.RSSI_CHANGED
- android.net.wifi.SCAN_RESULTS
- android.net.wifi.STATE_CHANGE
- android.net.wifi.WIFI_STATE_CHANGED
- android.net.wifi.supplicant.CONNECTION_CHANGE
- android.net.wifi.supplicant.STATE_CHANGE
- android.provider.Telephony.SIM_FULL
- android.provider.Telephony.SMS_RECEIVED
- android.provider.Telephony.WAP_PUSH_RECEIVED
- com.google.gservices.intent.action.GSERVICES_CHANGED
- android.bluetooth.a2dp.intent.action.SINK_STATE_CHANGED
- android.bluetooth.intent.action.BLUETOOTH_STATE_CHANGED
- android.bluetooth.intent.action.BOND_STATE_CHANGED_ACTION
- android.bluetooth.intent.action.DISCOVERY_COMPLETED
- android.bluetooth.intent.action.DISCOVERY_STARTED
- android.bluetooth.intent.action.HEADSET_ADUIO_STATE_CHANGED
- android.bluetooth.intent.action.HEADSET_STATE_CHANGED
- android.bluetooth.intent.action.NAME_CHANGED
- android.bluetooth.intent.action.PAIRING_CANCEL
- android.bluetooth.intent.action.PAIRING_REQUEST
- android.bluetooth.intent.action.REMOTE_DEVICE_CONNECTED
- android.bluetooth.intent.action.REMOTE_DEVICE_DISAPPEARED
- android.bluetooth.intent.action.REMOTE_DEVICE_DISAPPEARED
- android.bluetooth.intent.action.REMOTE_DEVICE_DISCONNECTED
- android.bluetooth.intent.action.REMOTE_DEVICE_DISCONNECT_REQUESTED
- android.bluetooth.intent.action.REMOTE_DEVICE_FOUND
- android.bluetooth.intent.action.REMOTE_NAME_FAILED
- android.bluetooth.intent.action.REMOTE_NAME_UPDATED
- android.bluetooth.intent.action.SCAN_MODE_CHANGED
- android.intent.action.AIRPLANE_MODE
- android.intent.action.BATTERY_CHANGED
- android.intent.action.BATTERY_LOW
- android.intent.action.BOOT_COMPLETED
- android.intent.action.CAMERA_BUTTON
- android.intent.action.CONFIGURATION_CHANGED
- android.intent.action.DATA_SMS_RECEIVED
- android.intent.action.DATE_CHANGED
- android.intent.action.DEVICE_STORAGE_LOW
- android.intent.action.DEVICE_STORAGE_OK
- android.intent.action.GTALK_CONNECTED
- android.intent.action.GTALK_DISCONNECTED
- android.intent.action.HEADSET_PLUG
- android.intent.action.INPUT_METHOD_CHANGED
- android.intent.action.MANAGE_PACKAGE_STORAGE
- android.intent.action.MEDIA_BAD_REMOVAL
- android.intent.action.MEDIA_BUTTON
- android.intent.action.MEDIA_CHECKING
- android.intent.action.MEDIA_EJECT
- android.intent.action.MEDIA_MOUNTED
- android.intent.action.MEDIA_NOFS
- android.intent.action.MEDIA_REMOVED
- android.intent.action.MEDIA_SCANNER_FINISHED
- android.intent.action.MEDIA_SCANNER_SCAN_FILE
- android.intent.action.MEDIA_SCANNER_STARTED
- android.intent.action.MEDIA_SHARED
- android.intent.action.MEDIA_UNMOUNTABLE
- android.intent.action.MEDIA_UNMOUNTED
- android.intent.action.NEW_OUTGOING_CALL
- android.intent.action.PACKAGE_ADDED
- android.intent.action.PACKAGE_CHANGED
- android.intent.action.PACKAGE_DATA_CLEARED
- android.intent.action.PACKAGE_INSTALL
- android.intent.action.PACKAGE_REMOVED
- android.intent.action.PACKAGE_REPLACED
- android.intent.action.PACKAGE_RESTARTED
- android.intent.action.PHONE_STATE
- android.intent.action.PROVIDER_CHANGED
- android.intent.action.REBOOT
- android.intent.action.SCREEN_OFF
- android.intent.action.SCREEN_ON
- android.intent.action.TIMEZONE_CHANGED
- android.intent.action.TIME_SET
- android.intent.action.TIME_TICK
- android.intent.action.UID_REMOVED
- android.intent.action.UMS_CONNECTED
- android.intent.action.UMS_DISCONNECTED
- android.intent.action.USER_PRESENT
- android.intent.action.WALLPAPER_CHANGED
- android.media.AUDIO_BECOMING_NOISY
- android.media.RINGER_MODE_CHANGED
- android.media.VIBRATE_SETTING_CHANGED
- android.net.conn.BACKGROUND_DATA_SETTING_CHANGED
- android.net.wifi.NETWORK_IDS_CHANGED
- android.net.wifi.RSSI_CHANGED
- android.net.wifi.SCAN_RESULTS
- android.net.wifi.STATE_CHANGE
- android.net.wifi.WIFI_STATE_CHANGED
- android.net.wifi.supplicant.CONNECTION_CHANGE
- android.net.wifi.supplicant.STATE_CHANGE
- android.provider.Telephony.SIM_FULL
- android.provider.Telephony.SMS_RECEIVED
- android.provider.Telephony.WAP_PUSH_RECEIVED
- com.google.gservices.intent.action.GSERVICES_CHANGED
Api Level 4 (SDK 1.6) 新增
- android.intent.action.ACTION_POWER_CONNECTED
- android.intent.action.ACTION_POWER_DISCONNECTED
- android.intent.action.ACTION_SHUTDOWN
- android.intent.action.BATTERY_OKAY
- android.speech.tts.TTS_QUEUE_PROCESSING_COMPLETED
- android.speech.tts.engine.TTS_DATA_INSTALLED
- com.google.gservices.intent.action.GSERVICES_OVERRIDE
- android.intent.action.ACTION_POWER_CONNECTED
- android.intent.action.ACTION_POWER_DISCONNECTED
- android.intent.action.ACTION_SHUTDOWN
- android.intent.action.BATTERY_OKAY
- android.speech.tts.TTS_QUEUE_PROCESSING_COMPLETED
- android.speech.tts.engine.TTS_DATA_INSTALLED
- com.google.gservices.intent.action.GSERVICES_OVERRIDE
Api Level 5 (SDK 2.0) 修改
- android.bluetooth.a2dp.action.SINK_STATE_CHANGED
- android.bluetooth.adapter.action.DISCOVERY_FINISHED
- android.bluetooth.adapter.action.DISCOVERY_STARTED
- android.bluetooth.adapter.action.LOCAL_NAME_CHANGED
- android.bluetooth.adapter.action.SCAN_MODE_CHANGED
- android.bluetooth.adapter.action.STATE_CHANGED
- android.bluetooth.device.action.ACL_CONNECTED
- android.bluetooth.device.action.ACL_DISCONNECTED
- android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED
- android.bluetooth.device.action.BOND_STATE_CHANGED
- android.bluetooth.device.action.CLASS_CHANGED
- android.bluetooth.device.action.FOUND
- android.bluetooth.device.action.NAME_CHANGED
- android.bluetooth.devicepicker.action.DEVICE_SELECTED
- android.bluetooth.devicepicker.action.LAUNCH
- android.bluetooth.headset.action.AUDIO_STATE_CHANGED
- android.bluetooth.headset.action.STATE_CHANGED
- android.bluetooth.a2dp.action.SINK_STATE_CHANGED
- android.bluetooth.adapter.action.DISCOVERY_FINISHED
- android.bluetooth.adapter.action.DISCOVERY_STARTED
- android.bluetooth.adapter.action.LOCAL_NAME_CHANGED
- android.bluetooth.adapter.action.SCAN_MODE_CHANGED
- android.bluetooth.adapter.action.STATE_CHANGED
- android.bluetooth.device.action.ACL_CONNECTED
- android.bluetooth.device.action.ACL_DISCONNECTED
- android.bluetooth.device.action.ACL_DISCONNECT_REQUESTED
- android.bluetooth.device.action.BOND_STATE_CHANGED
- android.bluetooth.device.action.CLASS_CHANGED
- android.bluetooth.device.action.FOUND
- android.bluetooth.device.action.NAME_CHANGED
- android.bluetooth.devicepicker.action.DEVICE_SELECTED
- android.bluetooth.devicepicker.action.LAUNCH
- android.bluetooth.headset.action.AUDIO_STATE_CHANGED
- android.bluetooth.headset.action.STATE_CHANGED
Api Level 5 (SDK 2.0) 新增
- android.intent.action.DOCK_EVENT
- android.provider.Telephony.SMS_REJECTED
- android.intent.action.DOCK_EVENT
- android.provider.Telephony.SMS_REJECTED
Api Level 7(SDK 2.1) 新增
- android.intent.action.LOCALE_CHANGED
- android.intent.action.LOCALE_CHANGED
Api Level 8(SDK 2.2) 新增
- android.app.action.ACTION_PASSWORD_CHANGED
- android.app.action.ACTION_PASSWORD_FAILED
- android.app.action.ACTION_PASSWORD_SUCCEEDED
- android.app.action.DEVICE_ADMIN_DISABLED
- android.app.action.DEVICE_ADMIN_DISABLE_REQUESTED
- android.app.action.DEVICE_ADMIN_ENABLED
- android.intent.action.EXTERNAL_APPLICATIONS_AVAILABLE
- android.intent.action.EXTERNAL_APPLICATIONS_UNAVAILABLE
- android.media.SCO_AUDIO_STATE_CHANGED
2010年2月4日 星期四
2010年2月3日 星期三
程式設計上的兩種Stub
- 不包含任何邏輯,純粹只是一個空的function,這種function叫做stub function
public void int sum(int a, int b) {
//do not calculate but return a constant number
return 0;
}
- 在分散式系統中,處理的function在remote端,而在local端設計一個function,接收local端的參數,然後再送交remote端處理。
public void int sum(int a, int b) {
//call remote function
mWebRMI.sum(a, b);
}
A stub in distributed computing is a piece of code used for converting parameters passed during a Remote Procedure Call (RPC).
2010年1月28日 星期四
Handler, Message, MessageQueue, Looper and Thread
- Handler是用來處理Message,在Message裡面的what欄位可以說明Message的種類,當Message送到Handler後,Handler會看這個Message的what欄位,再用相對應的邏輯處理。
- MessageQueue是一個FIFO的資料結構,可以把Message暫放在裡面等待被處理。
- Looper是一個用來將MessageQueue裡面的Message逐一送到Handler的類別。
- 由於Looper會佔住Main Thread的執行,所以通常會產生一個外部的Thread來幫忙執行。每一個Thread都有自己的Looper以及MessageQueue,可以在Thread中利用getLooper()來取得looper物件,然後再用Looper.myQueue()取得該Thread的MessageQueue來使用。
訂閱:
文章 (Atom)