adb(Android Debug Bridge)是Android提供的一個通用的調試工具,借助這個工具,我們可以管理設備或手機模擬器的狀態。還可以進行以下的操作:
1、快速更新設備或手機模擬器中的代碼,如應用或Android系統升級;
2、在設備上運行shell命令;
3、管理設備或手機模擬器上的預定端口;
4、在設備或手機模擬器上復制或粘貼文件;
以下為一些常用的操作:
1、安裝應用到模擬器:
adb install
比較郁悶的是,Android并沒有提供一個卸載應用的命令,只能自己手動刪除:
adb shell
cd /data/app
rm app.apk
(聽說可以這樣)
1. 1 卸載軟件[code]
adb uninstall
adb uninstall -k
[/code]如果加 -k 參數,為卸載軟件但是保留配置和緩存文件.
2、進入設備或模擬器的shell:
adb shell
通過上面的命令,就可以進入設備或模擬器的shell環境中,在這個Linux Shell中,你可以執行各種Linux的命令,另外如果只想執行一條shell命令,可以采用以下的方式:
adb shell [command]
如:adb shell dmesg會打印出內核的調試信息。
3、發布端口:
你可以設置任意的端口號,做為主機向模擬器或設備的請求端口。如:
adb forward tcp:5555 tcp:8000
4、復制文件:
你可向一個設備或從一個設備中復制文件,
復制一個文件或目錄到設備或模擬器上:
adb push
如:adb push test.txt /tmp/test.txt
從設備或模擬器上復制一個文件或目錄:
adb pull
如:adb pull /addroid/lib/libwebcore.so .
5、搜索模擬器/設備的實例:
取得當前運行的模擬器/設備的實例的列表及每個實例的狀態:
adb devices
6、查看bug報告:
adb bugreport
7、記錄無線通訊日志:
一般來說,無線通訊的日志非常多,在運行時沒必要去記錄,但我們還是可以通過命令,設置記錄:
adb shell
logcat -b radio
8、獲取設備的ID和序列號:
adb get-product
adb get-serialno
9、訪問數據庫SQLite3
adb shell
sqlite3
===============================
鍵入“cmd”,cd到tools的目錄下,再鍵入“adb shell”,出現了個“#”號,這樣就可以使用命令來控制Android了
運行“am -help”,可以查看“am”命令的幫助信息,試試運行“am start -n com.google.android.browser/com.google.android.browser.BrowserActivity”看看?呵呵,在模擬器里面可以看到運行了瀏覽器,哈哈,就是這么簡單(簡單個P,為了找這個東西花了我好久的時間)。
還有:
//運行瀏覽器,打開中華網
# am start -a android.intent.action.VIEW -d?http://www.china.com
am start -a android.intent.action.VIEW -d?http://www.china.com
Starting: Intent { action=android.intent.action.VIEW data=http://www.china.com }
//撥打電話,號碼是123456789
# am start -a android.intent.action.CALL -d tel:123456789
am start -a android.intent.action.CALL -d tel:123456789
Starting: Intent { action=android.intent.action.CALL data=tel:123456789 }
# am start -a android.intent.action.ALL_APPS
am start -a android.intent.action.ALL_APPS
Starting: Intent { action=android.intent.action.ALL_APPS }
//google地圖,到shanghai這個點包(注:點包為方言,就是地方的意思)
# am start -a android.intent.action.VIEW geo:0,0?q=shanghai
am start -a android.intent.action.VIEW geo:0,0?q=shanghai
Starting: Intent { action=android.intent.action.VIEW data=geo:0,0?q=shanghai }