Android命令行启动程序-am命令的使用

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 ] []

启动的方法为

# am start -n 包(package)名/活动(activity)全路径

查看包中每个activity的全路径的方法:

1、安装并启动“固件工具箱”

2、进入“App manager”,显示系统中所有安装程序,长按想通过命令行启动的程序。

3、弹出的窗口中选择"Advanced Freeze",该程序所有的activity就会全部显示出来

activity有两种显示格式,一种直接显示全路径,另一种在括号里显示相对路径,相对路径加上包名即是全路径。


几个启动指定程序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


通过adb shell 进入android 系统或者直接在命令前添加adb shell 


参考链接:http://blog.sina.com.cn/s/blog_677fbc190101l813.html

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 ] []

启动的方法为

# am start -n 包(package)名/活动(activity)全路径

查看包中每个activity的全路径的方法:

1、安装并启动“固件工具箱”

2、进入“App manager”,显示系统中所有安装程序,长按想通过命令行启动的程序。

3、弹出的窗口中选择"Advanced Freeze",该程序所有的activity就会全部显示出来

activity有两种显示格式,一种直接显示全路径,另一种在括号里显示相对路径,相对路径加上包名即是全路径。


几个启动指定程序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


通过adb shell 进入android 系统或者直接在命令前添加adb shell 


参考链接:http://blog.sina.com.cn/s/blog_677fbc190101l813.html

猜你喜欢

转载自blog.csdn.net/u010586698/article/details/64126229