我们怎样才能从我的Andr​​oid应用程序执行shell脚本文件 [英] How can we execute a shell script file from my Android Application

查看:98
本文介绍了我们怎样才能从我的Andr​​oid应用程序执行shell脚本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请告诉我就可以从我的Andr​​oid应用程序运行shell脚本文件。

Please Tell me it is possible to run a shell script file from My Android application.

和读取脚本文件中的数据。

and read the data from script file.

如果它比如何进行可能的话,请给我一些指导。

If it is possible than how to proceed , Please give me some guideline.

推荐答案

我一直在使用这在我的Andr​​oid应用程序运行shell脚本。只有我还没有搞清楚如何做的事情是直接输出到我想要的。你并不需要root这一点,这就是为什么我张贴。

I've been using this to run shell scripts in my android app. Only thing I've yet to figure out how to do is direct the output to where I want it. You don't need root for this, which is why I'm posting.

 Process process = Runtime.getRuntime().exec("top -n 1");
 //Get the output of top so that it can be read
 BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));

这篇关于我们怎样才能从我的Andr​​oid应用程序执行shell脚本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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