Android adb shell启动应用程序的方法
2016-04-27 16:32
435 查看
在Android中,除了从界面上启动程序之外,还可以从命令行启动程序,使用的是命令行工具am.
usage: am [subcommand] [options]
start an Activity: am start [-D]
-D: enable debugging
send a broadcast Intent: am broadcast
start an Instrumentation: am instrument [flags]
-r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
-e : set argument to
-p : write profiling data to
-w: wait for instrumentation to finish before returning
start profiling: am profile start
stop profiling: am profile stop
specifications include these flags:
[-a ] [-d ] [-t ]
[-c [-c ] ...]
[-e|--es ...]
[--ez ...]
[-e|--ei ...]
[-n ] [-f ] []
启动的方法为
$ adb shell
$ am start -n {包(package)名}/{包名}.{活动(activity)名称}
程序的入口类可以从每个应用的AndroidManifest.xml的文件中得到,以计算器(calculator)为例,它的
package="com.android.calculator2" …>…
由此计算器(calculator)的启动方法为:
# am start -n com.android.calculator2/com.android.calculator2.Calculator
对于HelloActivity这个示例工程,AndroidManifest.xml如下所示:
package="com.example.android.helloactivity" …>
由此它的启动方法为:
# am start -n com.example.android.helloactivity/com.example.android.helloactivity.HelloActivity
其他的一些应用启动命令,如下所示:
calendar(日历)的启动方法为:
# am start -n com.android.calendar/com.android.calendar.LaunchActivity
AlarmClock(闹钟)的启动方法为:
# am start -n com.android.alarmclock/com.android.alarmclock.AlarmClock
Music 和 Video(音乐和视频)的启动方法为:
# am start -n com.android.music/com.android.music.MusicBrowserActivity
# am start -n com.android.music/com.android.music.VideoBrowserActivity
# am start -n com.android.music/com.android.music.MediaPlaybackActivity
Camera(照相机)的启动方法为:
# am start -n com.android.camera/com.android.camera.Camera
Browser(浏览器)的启动方法为:
# am start -n com.android.browser/com.android.browser.BrowserActivity
一般情况希望,一个Android应用对应一个工程。值得注意的是,有一些工程具有多个活动(activity),而有一些应用使用一个工程。例如:在Android界面中,Music和Video是两个应用,但是它们使用的都是packages/apps/Music这一个工程。而在这个工程的AndroidManifest.xml文件中,有包含了不同的活动(activity)。
Music 和 Video(音乐和视频)的启动方法为:
# am start -n com.android.music/com.android.music.MusicBrowserActivity
# am start -n com.android.music/com.android.music.VideoBrowserActivity
# am start -n com.android.music/com.android.music.MediaPlaybackActivity
Camera(照相机)的启动方法为:
# am start -n com.android.camera/com.android.camera.Camera
Browser(浏览器)的启动方法为:
# am start -n com.android.browser/com.android.browser.BrowserActivity
启动浏览器 :
am start -a android.intent.action.VIEW -d http://www.google.cn/
拨打电话 :
am start -a android.intent.action.CALL -d tel:10086
启动 google map 直接定位到北京 :
am start -a android.intent.action.VIEW geo:0,0?q=beijing
url:http://greatverve.cnblogs.com/archive/2012/02/10/android-am.html
原文地址:http://blog.chinaunix.net/uid-26997997-id-3350449.html
usage: am [subcommand] [options]
start an Activity: am start [-D]
-D: enable debugging
send a broadcast Intent: am broadcast
start an Instrumentation: am instrument [flags]
-r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
-e : set argument to
-p : write profiling data to
-w: wait for instrumentation to finish before returning
start profiling: am profile start
stop profiling: am profile stop
specifications include these flags:
[-a ] [-d ] [-t ]
[-c [-c ] ...]
[-e|--es ...]
[--ez ...]
[-e|--ei ...]
[-n ] [-f ] []
启动的方法为
$ adb shell
$ am start -n {包(package)名}/{包名}.{活动(activity)名称}
程序的入口类可以从每个应用的AndroidManifest.xml的文件中得到,以计算器(calculator)为例,它的
package="com.android.calculator2" …>…
由此计算器(calculator)的启动方法为:
# am start -n com.android.calculator2/com.android.calculator2.Calculator
对于HelloActivity这个示例工程,AndroidManifest.xml如下所示:
package="com.example.android.helloactivity" …>
由此它的启动方法为:
# am start -n com.example.android.helloactivity/com.example.android.helloactivity.HelloActivity
其他的一些应用启动命令,如下所示:
calendar(日历)的启动方法为:
# am start -n com.android.calendar/com.android.calendar.LaunchActivity
AlarmClock(闹钟)的启动方法为:
# am start -n com.android.alarmclock/com.android.alarmclock.AlarmClock
Music 和 Video(音乐和视频)的启动方法为:
# am start -n com.android.music/com.android.music.MusicBrowserActivity
# am start -n com.android.music/com.android.music.VideoBrowserActivity
# am start -n com.android.music/com.android.music.MediaPlaybackActivity
Camera(照相机)的启动方法为:
# am start -n com.android.camera/com.android.camera.Camera
Browser(浏览器)的启动方法为:
# am start -n com.android.browser/com.android.browser.BrowserActivity
一般情况希望,一个Android应用对应一个工程。值得注意的是,有一些工程具有多个活动(activity),而有一些应用使用一个工程。例如:在Android界面中,Music和Video是两个应用,但是它们使用的都是packages/apps/Music这一个工程。而在这个工程的AndroidManifest.xml文件中,有包含了不同的活动(activity)。
Music 和 Video(音乐和视频)的启动方法为:
# am start -n com.android.music/com.android.music.MusicBrowserActivity
# am start -n com.android.music/com.android.music.VideoBrowserActivity
# am start -n com.android.music/com.android.music.MediaPlaybackActivity
Camera(照相机)的启动方法为:
# am start -n com.android.camera/com.android.camera.Camera
Browser(浏览器)的启动方法为:
# am start -n com.android.browser/com.android.browser.BrowserActivity
启动浏览器 :
am start -a android.intent.action.VIEW -d http://www.google.cn/
拨打电话 :
am start -a android.intent.action.CALL -d tel:10086
启动 google map 直接定位到北京 :
am start -a android.intent.action.VIEW geo:0,0?q=beijing
url:http://greatverve.cnblogs.com/archive/2012/02/10/android-am.html
原文地址:http://blog.chinaunix.net/uid-26997997-id-3350449.html
相关文章推荐
- BASH SHELL下两个用于检查端口情况的脚本
- shell-awk高级应用
- 让shell脚本在后台运行的两种方法
- 使用sed替换替换指定行的日期部分
- Shell 更好看的回显
- 使用shell脚本显示出当前路径或者去掉目录路径
- 用shell脚本挂载linux主机拷贝相应文件copy.sh
- 用shell脚本挂载linux主机拷贝相应文件copy.sh
- 用shell脚本挂载linux主机拷贝相应文件copy.sh
- 用shell脚本挂载linux主机拷贝相应文件
- 用shell脚本挂载linux主机拷贝相应文件
- 用shell脚本挂载linux主机拷贝相应文件
- Makefile里调用Shell注意点
- Create and Use a Custom Formatter in the Apache HBase Shell
- 使用Powershell批量获取Exchange 2013邮箱用户容量使用量
- Linux下通过shell批量替换文件内容
- Makefile与Shell的问题
- Makefile与shell脚本区别
- linux 开机自动启动 shell
- Xshell输入enter全屏的问题解决