Android am start 命令详解
start [options]
option:
-D: Enable debugging.
-W: Wait for launch to complete.
–start-profiler : Start profiler and send results to .
-P : Like --start-profiler, but profiling stops when the app goes idle.
-R: Repeat the activity launch 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.
-a
启动时,要执行的动作,如:android.intent.action.VIEW,也可以自己定义action
-d <DATA_URI>
启动时,要传入的URI
-t <MIME_TYPE>
启动时的文件类型,视频,音频,还是网页
-c
-n
直接启动一个组件,例如:adb shell am start -n com.example.app/.ExampleActivity
注:在windows下执行下述命令时
am start -a com.vod.action.videoplayer.open -d"video2://?video_id=7LM3dd.dF6df0be0e2b5c2ab1&cover_id=7LM3dd.M.2e7bd2d836927fd7&vendorId=327"
发现应用在接收到intent后,intent中的参数变为“video2://?video_id=7LM3dd.M.2e7bd2d836927fd7”。$符号后的数据被截断了。
原因:
adb shell相当于是在linux shell环境下运行的,而&符号是shell中的特殊字符,表示后台运行,因此会出现截断的情况
解决方法
1.
adb shell
am start -a com.vod.action.videoplayer.open -d"video2://?video_id=7LM3dd.dF6df0be0e2b5c2ab1&cover_id=7LM3dd.M.2e7bd2d836927fd7&vendorId=327"
adb shell am start -a com.vod.action.videoplayer.open -d"video2://?video_id=7LM3dd.dF6df0be0e2b5c2ab1&cover_id=7LM3dd.M.2e7bd2d836927fd7'&'vendorId=327"