Android am/pm命令用法

am命令的参数介绍:

usage: am [subcommand] [options]

    start an Activity: am start [-D] <INTENT>
        -D: enable debugging

    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

    <INTENT> specifications include these flags:
        [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]
        [-c <CATEGORY> [-c <CATEGORY>] ...]
        [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]
        [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]
        [-e|--ei <EXTRA_KEY> <EXTRA_INT_VALUE> ...]
        [-n <COMPONENT>] [-f <FLAGS>] [<URI>]

tips:你也可以在终端下输入adb shell am 查看更多使用方法

具体使用方法:

am start -n 包(package)名/包名.活动(activity)名称
启动的方法可以从每个应用的AndroidManifest.xml的文件中得到

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.baidu.com/

拨打电话 :
am start -a android.intent.action.CALL -d tel:10086

启动 google map 直接定位到北京 :
am start -a android.intent.action.VIEW geo:0,0?q=beijing

安卓am命令有很多个参数及使用方法,具体可参考官方网站:Android Debug Bridge

==================================================

pm命令的参数介绍如下:

usage: pm [list|path|install|uninstall] 
       pm list packages [-f] 
       pm list permission-groups 
       pm list permissions [-g] [-f] [-d] [-u] [GROUP] 
       pm list instrumentation [-f] [TARGET-PACKAGE] 
       pm path PACKAGE 
       pm install [-l] [-r] PATH 
       pm uninstall [-k] PACKAGE 
       pm enable PACKAGE_OR_COMPONENT 
       pm disable PACKAGE_OR_COMPONENT

The list packages command prints all packages.  Use 
the -f option to see their associated file.

The list permission-groups command prints all known 
permission groups.

The list permissions command prints all known 
permissions, optionally only those in GROUP.  Use 
the -g option to organize by group.  Use 
the -f option to print all information.  Use 
the -s option for a short summary.  Use 
the -d option to only list dangerous permissions.  Use 
the -u option to list only the permissions users will see.

The list instrumentation command prints all instrumentations, 
or only those that target a specified package.  Use the -f option 
to see their associated file.

The path command prints the path to the .apk of a package.

The install command installs a package to the system.  Use 
the -l option to install the package with FORWARD_LOCK. Use 
the -r option to reinstall an exisiting app, keeping its data.

The uninstall command removes a package from the system. Use 
the -k option to keep the data and cache directories around 
after the package removal.

tips:你也可以在终端下输入adb shell pm 查看更多使用方法

具体使用方法:

1.1:察看已安装的包:
pm list package
此时则显示所有已经安装的包名。

pm list package -f
也显示associated文件所在目录(即保存的APK文件)

1.2:察看已知的权限组:
pm list permission-groups

1.3:察看所有已知的权限:
pm list permissions

1.4:列出所有硬件相关信息:
pm list features

结果通常类似:
feature:reqGlEsVersion=0x20000
feature:android.hardware.bluetooth
feature:android.hardware.camera
feature:android.hardware.location
feature:android.hardware.location.network
feature:android.hardware.microphone
feature:android.hardware.sensor.accelerometer
feature:android.hardware.sensor.compass
feature:android.hardware.touchscreen
feature:android.hardware.wifi

1.5:列出指定包名的 associated 文件 (APK存档文件) 所在:
例如:
pm path com.cai.test
package:/mnt/asec/com.cai.test-1/test.apk

1.6: 安装APK:
pm install [-l] [-r] [-t] [-i INSTALLER_PACKAGE_NAME] [-s] [-f] PATH

PATH 指 APK文件绝对路径和文件名。

例如:
pm install /data/test.apk

这几个参数很有用:
-r: 安装一个已经安装的APK,保持其数据不变。
-i:指定安装的包名。(没试出来)
-s: 安装到SDCard上。
-f: 安装到内部Flash上。

1.6:卸载APK:
pm uninstall 包名。
例如:
pm uninstall com.cai.test

1.7: 得到和设置缺省安装位置:
The getInstallLocation command gets 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
The setInstallLocation command changes the default install location
0 [auto]: Let system decide the best location
1 [internal]: Install on internal device storage
2 [external]: Install on external media

pm getInstallLocation
得到缺省的安装位置。

设置:
pm setInstallLocation <0|1|2>

0: 自动。
1:内部Flash。
2:扩展存储设备。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值