adb命令

第一篇:adb shell am 的用法(转子:http://blog.youkuaiyun.com/fulinwsuafcie/article/details/8092459)

adb shell am 的功能
adb shell am
使用此命令可以从cmd控制台启动 activity, services;发送 broadcast等等:
C:\Users\Administrator>adb shell am
usage: am [subcommand] [options]

    start an Activity: am start [-D] [-W] <INTENT>
        -D: enable debugging
        -W: wait for launch to complete

    start a Service: am startservice <INTENT>

    send a broadcast Intent: am broadcast <INTENT>

    start an Instrumentation: am instrument [flags] <COMPONENT>
        -r: print raw results (otherwise decode REPORT_KEY_STREAMRESULT)
        -e <NAME> <VALUE>: set argument <NAME> to <VALUE>
        -p <FILE>: write profiling data to <FILE>
        -w: wait for instrumentation to finish before returning

    start profiling: am profile <PROCESS> start <FILE>
    stop profiling: am profile <PROCESS> stop

    start monitoring: am monitor [--gdb <port>]
        --gdb: start gdbserv on the given port at crash/ANR

    <INTENT> specifications include these flags:
        [-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> ...]
        [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
        [-n <COMPONENT>] [-f <FLAGS>]
        [--grant-read-uri-permission] [--grant-write-uri-permission]
        [--debug-log-resolution]
        [--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]
        [--receiver-registered-only] [--receiver-replace-pending]
        [<URI>]


使用实例:
如启动一个 Activity:

格式:
adb shell am start -n 包名/包名+类名(-n 类名,-a action,-d date,-m MIME-TYPE,-c category,-e 扩展数据,等)。
 
实例1:
C:\Users\Administrator>adb shell am start -n com.android.camera/.Camera
Starting: Intent { cmp=com.android.camera/.Camera }
 
实例2:(带extra 的 intent)
C:\Users\Administrator>adb shell am start -n com.android.camera/.Camera -e abc hello
Starting: Intent { cmp=com.android.camera/.Camera (has extras) }
其中 extra 的 key 为 abc ,value 为字串 "hello"


第二篇: adb shell pm 命令(转自:http://blog.sina.com.cn/s/blog_4e9b076e01016d8a.html)

adb shell pm 命令详细

usage: pm list packages [-f] [-d] [-e] [-s] [-3] [-i] [-u] [FILTER]

       pm list permission-groups

       pm list permissions [-g] [-f] [-d] [-u] [GROUP]

       pm list instrumentation [-f] [TARGET-PACKAGE]

       pm list features

       pm list libraries

       pm path PACKAGE

       pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f]

                  [--algo --key --iv ] PATH

       pm uninstall [-k] PACKAGE

       pm clear PACKAGE

       pm enable PACKAGE_OR_COMPONENT

       pm disable PACKAGE_OR_COMPONENT

       pm disable-user PACKAGE_OR_COMPONENT

       pm grant PACKAGE PERMISSION

       pm revoke PACKAGE PERMISSION

       pm set-install-location [0/auto] [1/internal] [2/external]

       pm get-install-location

       pm set-permission-enforced PERMISSION [true|false]



pm list packages: prints all packages, optionally only

  those whose package name contains the text in FILTER.  Options:

    -f: see their associated file.

    -d: filter to only show disbled packages.

    -e: filter to only show enabled packages.

    -s: filter to only show system packages.

    -3: filter to only show third party packages.

    -i: see the installer for the packages.

    -u: also include uninstalled packages.



pm list permission-groups: prints all known permission groups.



pm list permissions: prints all known permissions, optionally only

  those in GROUP.  Options:

    -g: organize by group.

    -f: print all information.

    -s: short summary.

    -d: only list dangerous permissions.

    -u: list only the permissions users will see.



pm list instrumentation: use to list all test packages; optionally

  supply to list the test packages for a particular

  application.  Options:

    -f: list the .apk file for the test package.



pm list features: prints all features of the system.



pm path: print the path to the .apk of the given PACKAGE.



pm install: installs a package to the system.  Options:

    -l: install the package with FORWARD_LOCK.

    -r: reinstall an exisiting app, keeping its data.

    -t: allow test .apks to be installed.

    -i: specify the installer package name.

    -s: install package on sdcard.

    -f: install package on internal flash.



pm uninstall: removes a package from the system. Options:

    -k: keep the data and cache directories around after package removal.



pm clear: deletes all data associated with a package.



pm enable, disable, disable-user: these commands change the enabled state

  of a given package or component (written as "package/class").



pm grant, revoke: these commands either grant or revoke permissions

  to applications.  Only optional permissions the application has

  declared can be granted or revoked.



pm get-install-location: returns the current install location.

    0 [auto]: Let system decide the best location

    1 [internal]: Install on internal device storage

    2 [external]: Install on external media



pm set-install-location: changes the default install location.

  NOTE: this is only intended for debugging; using this can cause

  applications to break and other undersireable behavior.

    0 [auto]: Let system decide the best location

    1 [internal]: Install on internal device storage

    2 [external]: Install on external media

第三篇:Android系统在超级终端下必会的命令大全(adb shell命令大全):转自:http://blog.youkuaiyun.com/neiloid/article/details/7037093

第四篇:http://changxianli6121.blog.163.com/blog/static/56392130201322805518442/

第五篇:adb logcat 基本用法:http://blog.youkuaiyun.com/fulinwsuafcie/article/details/8028572

### ADB命令使用教程和常见操作 #### 一、ADB简介 安卓调试桥 (Android Debug Bridge, adb),是一种可以用来操作手机设备或模拟器的命令行工具。作为 Android 开发/测试人员的重要工具,它允许与连接的Android设备进行通信[^1]。 #### 二、ADB环境部署 为了能够正常使用ADB,需先安装并配置好开发环境。通常建议安装 Android Studio,在其 SDK 中包含了必要的平台工具。具体来说,需要将 `D:\develop_tools\Android\SDK\platform-tools` 这样的路径加入系统的环境变量中以便全局调用adb命令。完成后可以在任意位置打开命令提示符窗口并通过输入 `adb version` 来验证安装情况以及确认当前使用的版本号[^2]。 #### 三、基本语法结构 ADB命令遵循特定格式来执行不同功能的操作。一般形式为: ```bash adb [-d|-e|-s <serialNumber>] <command> ``` 其中 `-d`, `-e`, 或者 `-s` 参数用于指定目标设备;而 `<command>` 则代表实际要运行的具体指令。 #### 四、常用命令列表 ##### 4.1 获取帮助文档 当不确定如何使用某个命令时,可以通过下面的方式获取详细的帮助信息: ```bash adb help # 或者更简洁的形式 adb --help ``` 这会列出所有可用的功能选项及其说明[^3]。 ##### 4.2 设备管理 - **查看已连接设备** ```bash adb devices ``` - **重启设备** ```bash adb reboot ``` - **进入恢复模式** ```bash adb reboot recovery ``` ##### 4.3 文件传输 - **推送文件至设备** ```bash adb push local_file remote_directory ``` - **拉取文件自设备** ```bash adb pull remote_file local_directory ``` ##### 4.4 应用程序处理 - **安装APK包** ```bash adb install apk_path ``` - **卸载应用程序** ```bash adb uninstall package_name ``` ##### 4.5 日志记录 - **实时监控日志输出** ```bash adb logcat ``` 以上仅列举了一些基础却非常实用的例子,实际上还有更多高级特性等待探索。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值