Android系统下好用的shell命令

来源:互联网 发布:java webservice传xml 编辑:程序博客网 时间:2024/06/06 09:50


首先要知道am其实就是ActivityManager的缩写!

使用am可以很方便执行很多操作,比如启动一个应用,启动一个服务,发送一个广播 ,等等。。。
 
   下面是一个通用的参数,通过这写参数就可以很好的使用上面的功能:

    

    [-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> ...]    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]        (mutiple extras passed as Integer[])    [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]        (mutiple extras passed as List<Integer>)    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]        (mutiple extras passed as Long[])    [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]        (mutiple extras passed as List<Long>)    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]        (mutiple extras passed as Float[])    [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]        (mutiple extras passed as List<Float>)    [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]        (mutiple extras passed as String[]; to embed a comma into a string,         escape it using "\,")    [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]        (mutiple extras passed as List<String>; to embed a comma into a string,         escape it using "\,")    [--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]    [--selector]    [<URI> | <PACKAGE> | <COMPONENT>]    [-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> ...]    [--ef <EXTRA_KEY> <EXTRA_FLOAT_VALUE> ...]    [--eu <EXTRA_KEY> <EXTRA_URI_VALUE> ...]    [--ecn <EXTRA_KEY> <EXTRA_COMPONENT_NAME_VALUE>]    [--eia <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]        (mutiple extras passed as Integer[])    [--eial <EXTRA_KEY> <EXTRA_INT_VALUE>[,<EXTRA_INT_VALUE...]]        (mutiple extras passed as List<Integer>)    [--ela <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]        (mutiple extras passed as Long[])    [--elal <EXTRA_KEY> <EXTRA_LONG_VALUE>[,<EXTRA_LONG_VALUE...]]        (mutiple extras passed as List<Long>)    [--efa <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]        (mutiple extras passed as Float[])    [--efal <EXTRA_KEY> <EXTRA_FLOAT_VALUE>[,<EXTRA_FLOAT_VALUE...]]        (mutiple extras passed as List<Float>)    [--esa <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]        (mutiple extras passed as String[]; to embed a comma into a string,         escape it using "\,")    [--esal <EXTRA_KEY> <EXTRA_STRING_VALUE>[,<EXTRA_STRING_VALUE...]]        (mutiple extras passed as List<String>; to embed a comma into a string,         escape it using "\,")    [--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]    [--selector]    [<URI> | <PACKAGE> | <COMPONENT>]

  1. 启动一个应用:

        adb shell am start -n "com.example.huanglei.test/com.example.huanglei.test.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER

        -D: enable debugging    -W: wait for launch to complete    --start-profiler <FILE>: start profiler and send results to <FILE>    --sampling INTERVAL: use sample profiling with INTERVAL microseconds        between samples (use with --start-profiler)    -P <FILE>: like above, but profiling stops when app goes idle    -R: repeat the activity launch <COUNT> times.  Prior to each repeat,        the top activity will be finished.    -S: force stop the target app before starting the activity    --opengl-trace: enable tracing of OpenGL functions    --user <USER_ID> | current: Specify which user to run as; if not        specified then run as the current user.
  2. 启动一个服务:
    adb shell am startservice -a ecarx.intent.action.NAVI_SERVICE_STARTED -c ecarx.intent.category.NAVI
  3. 发送一个广播:
    adb shell am broadcast -a com.haley.b.TEST_ACTION

wm    (WindowManager) 用来管理窗口的,比如获取和设置屏幕的分辨率,可以通过设置这个值来查看你的做的界面是否适配很方便。                                                   usage: wm [subcommand] [options]                                                
       wm size [reset|WxH]                                                      
       wm density [reset|DENSITY]                                               
       wm overscan [reset|LEFT,TOP,RIGHT,BOTTOM]   


0 0
原创粉丝点击