任何以编程方式在android上运行shell命令的方法? [英] Any way to run shell commands on android programmatically?

查看:24
本文介绍了任何以编程方式在android上运行shell命令的方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么办法可以在我的应用程序上运行终端命令,然后访问我的 UI 上的数据?特别是top.

Is there any way to run terminal commands on my application and then access the data on my UI? Specifically top.

推荐答案

以 Log Collector 为例.这是 相关文件.

Check out Log Collector as an example. Here is the relevant file.

关键在这里:

ArrayList<String> commandLine = new ArrayList<String>();
commandLine.add("logcat");//$NON-NLS-1$
[...]

Process process = Runtime.getRuntime().exec(commandLine);
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

这篇关于任何以编程方式在android上运行shell命令的方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆