使用Android(安卓)adb命令来启动Android应用程序
16lz
2021-12-04
使用Android adb命令来启动Android应用程序
Android自带的ADB工具是一个很强大的工具,我们可以用ADB来完成非常多的工作。
具体ADB的使用可以参考这篇文章:Android adb常用指令使用指南
如何安装一个android app程序,可以使用adb install ApkName.apk命令来实现,那么安装完成之后可不可以用命令行来启动它呢?
Of Course!!!
那么如何启动已经安装好的Android App程序吗?
我们可以在命令行输入一下内容:
- C:\Users\Administrator>adbshellamstart-aandroid.intent.action.MAIN-candroid.intent.category.LAUNCHER-nnet.micod
- e.fileexplorer/net.micode.fileexplorer.FileExplorerTabActivity
- Starting:Intent{act=android.intent.action.MAINcat=[android.intent.category.LAUNCHER]cmp=net.micode.fileexplorer/.Fi
- leExplorerTabActivity}
有同学要说,上面的命令太长了,不好记,老师,能不能给力点?
好的,我们可以精简下:
[plain] view plain copy- C:\Users\Administrator>adbshellamstart-nnet.micode.fileexplorer/net.micode.fileexplorer.FileExplorerTabActivity
- Starting:Intent{cmp=net.micode.fileexplorer/.FileExplorerTabActivity}
- C:\Users\Administrator>
其中FileExplorerTabActivity是fileexplorerApp应用程序的类名。
我们来看下adb shell am命令的帮助。
- C:\Users\Administrator>adbshellam
- usage:am[subcommand][options]
- usage:amstart[-D][-W][-P<FILE>][--start-profiler<FILE>]
- [--RCOUNT][-S]<INTENT>
- amstartservice<INTENT>
- amforce-stop<PACKAGE>
- amkill<PACKAGE>
- amkill-all
- ambroadcast<INTENT>
- aminstrument[-r][-e<NAME><VALUE>][-p<FILE>][-w]
- [--no-window-animation]<COMPONENT>
- amprofile[looper]start<PROCESS><FILE>
- amprofile[looper]stop[<PROCESS>]
- amdumpheap[flags]<PROCESS><FILE>
- amset-debug-app[-w][--persistent]<PACKAGE>
- amclear-debug-app
- ammonitor[--gdb<port>]
- amscreen-compat[on|off]<PACKAGE>
- amdisplay-size[reset|MxN]
- amto-uri[INTENT]
- amto-intent-uri[INTENT]
- amstart:startanActivity.Optionsare:
- -D:enabledebugging
- -W:waitforlaunchtocomplete
- --start-profiler<FILE>:startprofilerandsendresultsto<FILE>
- -P<FILE>:likeabove,butprofilingstopswhenappgoesidle
- -R:repeattheactivitylaunch<COUNT>times.Priortoeachrepeat,
- thetopactivitywillbefinished.
- -S:forcestopthetargetappbeforestartingtheactivity
- amstartservice:startaService.
- amforce-stop:forcestopeverythingassociatedwith<PACKAGE>.
- amkill:Killallprocessesassociatedwith<PACKAGE>.Onlykills.
- processesthataresafetokill--thatis,willnotimpacttheuser
- experience.
- amkill-all:Killallbackgroundprocesses.
- ambroadcast:sendabroadcastIntent.
- aminstrument:startanInstrumentation.Typicallythistarget<COMPONENT>
- istheform<TEST_PACKAGE>/<RUNNER_CLASS>.Optionsare:
- -r:printrawresults(otherwisedecodeREPORT_KEY_STREAMRESULT).Usewith
- [-eperftrue]togeneraterawoutputforperformancemeasurements.
- -e<NAME><VALUE>:setargument<NAME>to<VALUE>.Fortestrunnersa
- commonformis[-e<testrunner_flag><value>[,<value>...]].
- -p<FILE>:writeprofilingdatato<FILE>
- -w:waitforinstrumentationtofinishbeforereturning.Requiredfor
- testrunners.
- --no-window-animation:turnoffwindowanimationswillrunning.
- amprofile:startandstopprofileronaprocess.
- amdumpheap:dumptheheapofaprocess.Optionsare:
- -n:dumpnativeheapinsteadofmanagedheap
- amset-debug-app:setapplication<PACKAGE>todebug.Optionsare:
- -w:waitfordebuggerwhenapplicationstarts
- --persistent:retainthisvalue
- amclear-debug-app:clearthepreviouslyset-debug-app.
- ammonitor:startmonitoringforcrashesorANRs.
- --gdb:startgdbservonthegivenportatcrash/ANR
- amscreen-compat:controlscreencompatibilitymodeof<PACKAGE>.
- amdisplay-size:overridedisplaysize.
- amto-uri:printthegivenIntentspecificationasaURI.
- amto-intent-uri:printthegivenIntentspecificationasanintent:URI.
- <INTENT>specificationsincludetheseflagsandarguments:
- [-a<ACTION>][-d<DATA_URI>][-t<MIME_TYPE>]
- [-c<CATEGORY>[-c<CATEGORY>]...]
- [-e|--es<EXTRA_KEY><EXTRA_STRING_VALUE>...]
- [--esn<EXTRA_KEY>...]
- [--ez<EXTRA_KEY><EXTRA_BOOLEAN_VALUE>...]
- [--ei<EXTRA_KEY><EXTRA_INT_VALUE>...]
- [--el<EXTRA_KEY><EXTRA_LONG_VALUE>...]
- [--eu<EXTRA_KEY><EXTRA_URI_VALUE>...]
- [--eia<EXTRA_KEY><EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]
- [--ela<EXTRA_KEY><EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]
- [-n<COMPONENT>][-f<FLAGS>]
- [--grant-read-uri-permission][--grant-write-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]
- [--selector]
- [<URI>|<PACKAGE>|<COMPONENT>]
来源:http://blog.csdn.net/tcpipstack/article/details/8553965
更多相关文章
- Android的一些常用命令提示符(cmd)指令
- Android(安卓)Launcher 分析
- Android应用程序窗口(Activity)的运行上下文环境(Context)的创建过程
- 命令行下Android应用开发
- Android编译详解之lunch命令
- Android上的单元测试
- Android启动页上下白屏适配
- Android(安卓)快速运行的秘诀
- 理解Android(安卓)上的安全性