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

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

问题描述

有什么办法上运行我的应用程序的终端命令,然后进入我的UI中的数据?具体来说

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

推荐答案

查看日志收集作为一个例子。这里是<一个href="http://$c$c.google.com/p/android-log-collector/source/browse/trunk/src/com/xtralogic/android/logcollector/SendLogActivity.java?r=2">relevant文件。

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天全站免登陆