Android AM命令行启动程序的方法

来源:互联网 发布:清华软件学院排名 编辑:程序博客网 时间:2024/06/05 23:03
am start -n com.android.settings/com.android.settings.Settings &
am start -n com.android.settings/com.android.settings.SoundAndDisplaySettings &
am start -n com.android.music/com.android.music.MediaPlaybackActivity -d file:///a.ogg &

其实就是去文件packages/apps/Settings/AndroidManifest.xml中观看
package="com.android.settings"
然后所有activity的名字都可以使用上面的am start -n启动了
am start -n package/package.Activityname -d Uri &
手机可以adb shell && am --help 查看更加详细的语法
拨电话号码
am start -a android.intent.action.DIAL -d tel:0800000123 &
直接打该号码(需要将packages/apps/Phone/AndroidManifest.xml中含有
"android.intent.action.CALL"的所在activity即"OutgoingCallBroadcaster"
包含的android:permission="android.permission.CALL_PHONE"去掉才行
)
am start -a android.intent.action.CALL -d tel:0800000123 &
上网
am start -a android.intent.action.VIEW -d http://www.baidu.com &
发邮件
am start -a android.intent.action.SENDTO -d mailto:gliethttp@123.com &
显示地图
am start -a android.intent.action.SENDTO -d "geo:38.899533,-77.036476" &

am start -a android.intent.action.VIEW -d file:///a.ogg -t audio/* &
am start -a android.intent.action.VIEW -d file:///sdcard/chujia.mp3 -t audio/* &
am start -a android.intent.action.VIEW -d file:///b.mp4 -t video/* &
am start -a android.intent.action.VIEW -d file:///c.jpg -t image/* &
am start -D -d file:///chujia.mp3 -t audio/* &
am start -a android.intent.action.SEARCH -d file:///chujia.mp3 -t audio/* &

这里的am -a参数表示执行一个action动作,后面的audio/*表示数据mime类型,
Android将自动查找mime类型对应的所有文件中和-d指定一致的文件,
同样mime类型具体数值可以去文件packages/apps/Music/AndroidManifest.xml中观看