如何在java.lang.Runtime.getRuntime()中编写adb shell command?
我需要使用 adb connect pc to device 并进行一些检查。 所以我尝试使用 java.lang.Runtime.getRuntime().exec(cmd)
将 adb
shell 结果获取到我的程序中。 但我不知道如何在 exec
调用中编写 adb shell 命令, 类似于:
String cmd =adkHome + "adb.exe -s " + device + " shell ls";
然后 cd data/app
我该怎么做?
I need to use adb connect pc to device and do some checking.
So I try to usejava.lang.Runtime.getRuntime().exec(cmd)
to get adb
shell result into my program.
But I don't know how to write the adb shell commend in the exec
call,
something like:
String cmd =adkHome + "adb.exe -s " + device + " shell ls";
then cd data/app
How do I do this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这可能就是您正在寻找的?
至于在 shell 中执行操作,我建议编写一个您执行的 shell 脚本。在这种情况下而不是
Replace it with
干杯!
This may be what you're looking for?
As far as preforming actions in a shell, I would recommend writing a shell script that you execute. In this case instead of
Replace it with
Cheers!
如果您打算通过 Java 应用程序在手机上运行此程序,您只需要:
If you mean to run this on the phone from your java app, you just need: