如何执行壳牌通过Android应用程序的命令? [英] How to Executing Shell commands through android app?
本文介绍了如何执行壳牌通过Android应用程序的命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
首先,我是新来的Android。
Firstly I'm new to Android.
如何执行下面的shell命令
How to execute the following shell command
echo "1" > /sys/devices/enable
在一个Android应用程序。
in an android app.
我提到很多环节的,但我没有得到解决。
I referred many link's but I didn't get the solution.
有没有办法,我要提到的manifest文件来执行shell命令在应用程序的任何许可???
Is there any permission that I should mention in the manifest file to execute the shell commands in the app???.
在此先感谢。
推荐答案
为什么在Java中不写?
Why not write in Java?
try{
FileWriter fw = new FileWriter(new File("/sys/devices/enable"));
fw.write('1');
fw.close();
}catch(IOExceprion e){}
如果你真的想调用一个shell,试试这个:
If you really want to invoke a shell, try this:
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(new String[]{"/system/bin/sh", "-c", "echo \"1\" > /sys/devices/enable");
尝试上述任何一种方法之前,可以先
请确保您的设备是植根第一。
Make sure your device is rooted first before trying any of the above mentioned approaches.
这篇关于如何执行壳牌通过Android应用程序的命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文