適用於linux 環境 和 adb shell 下
//撥打**
am start -a android.intent.action.call -d tel:
10086
//開啟**www.baidu.com
//啟動activity
am start [options]
am start -n 包(
package
)名/包名.活動(activity)名稱
am start -n com.yoshin.test/
.mainactivity
//啟動activity,攜帶引數。包名為com.yoshin.test,主activity為.mainactivity,且extra資料以」key」為key, 「value」為value。
am start -n com.yoshin.test/
.mainactivity -es key value
//傳送廣播
am broadcast
am broadcas
--es myaction
//啟動service
am startservice
//停止service
am stopservice
//殺指定後台程序
am kill
//殺所有後台程序
am kill -all
//強殺程序,作用相當於退出,適用於卡死
am force -stop
//系統卡住
am hang
//重啟
am restart
或者 am reboot
下面這幾個命令沒有使用過:
//建立bugreport
am bug -report
//程序pid的堆資訊輸出到file
am dumpheap
//收緊程序的記憶體
am send-trim-memory
//監控
am monitor
[options] 引數講解
-d: 允許除錯功能
-r : 重複啟動activity count次
-s: 啟動activity之前,先呼叫forcestoppackage
(–opengl-trace: 執行獲取opengl函式的trace
–start-profiler : 啟動profiler,並將結果傳送到 ;
–sampling interval: 設定profiler 取樣時間間隔,單位ms;
[intent-常用] 引數講解
常用引數
-a : 指定intent action, 實現原理intent.
setaction
();
-n : 指定元件名,格式為/.
,實現原理intent.
setcomponent
();
-d : 指定intent data uri
-t : 指定intent mime type
-c [
-c ] …]
:指定intent category,實現原理intent.
addcategory()
-p : 指定包名,實現原理intent.
setpackage()
;-f : 新增flags,實現原理intent.
setflags
(int
),緊接著的引數必須是int型;
[intent-extra] 引數講解
引數與型別一一對應:
基本型別
引數 -e/
-es -esn -ez -ei -el -ef -eu -ecn
型別 string (string)null boolean
intlong
float uri component
陣列型別
引數 -esa -eia -ela -efa
陣列型別 string[
]int
long
float
arraylist型別
引數 -esal -eial -elal -efal
list型別 string int
long
float
[intent-flags] 引數講解
[
--grant-read-uri-permission]
[--grant-write-uri-permission]
[--grant-persistable-uri-permission]
[--grant-prefix-uri-permission]
[--debug-log-resolution]
[--exclude-stopped-packages]
[--include-stopped-packages]
[--activity-brought-to-front]
[--activity-clear-top]
[--activity-clear-when-task-reset]
[--activity-exclude-from-recents]
[--activity-launched-from-history]
[--activity-multiple-task]
[--activity-no-animation]
[--activity-no-history]
[--activity-no-user-action]
[--activity-previous-is-top]
[--activity-reorder-to-front]
[--activity-reset-task-
if-needed]
[--activity-single-top]
[--activity-clear-task]
[--activity-task-on-home]
[--receiver-registered-only]
[--receiver-replace-pending]
例如,傳送action=」broadcast.demo」的廣播,並且對於forcestoppackage()的應用不允許接收該廣播,命令如下:
am broadcast -a broadcast.demo --exclude-stopped-packages
每天記錄學習的新知識 getParentFile
用於獲取檔案的目錄結構.一般用於操作檔案前,對檔案的目錄結構審查 file fileparent file.getparentfile 乙個簡單的小例子,用於建立檔案前,確保檔案目錄滅有問題。string strpath e a aa aaa.txt file file new file strpa...
每天記錄學習的新知識 RM 刪除命令
rm是linux命令 刪除檔案時,盡量使用絕對路徑或者進入到目標路徑下後使用刪除命令。禁止使用rm rf 檔案 少個 就是根目錄,會造成不可回退的災難 語法 rm options name.rm 選項 引數 引數為目錄或檔案 刪除當前目錄下的所有檔案及目錄,並且是直接刪除,無需逐一確認命令行為 rm...
學習新知識的方法
先了解知識的背景,然後了解該知識要解決的問題,最後了解知識的目的。知識的背景 這個知識產生的原因,是在什麼情況下產生的,這個知識產生之後,問題解決了多少,解決到什麼程度。舉例 泰勒公式的目的就是為了用多項式更好地擬合複雜函式,使得複雜函式可以做更多的事情。學到的知識要去實踐,才能對其精髓體會更深。先...