brother recently wanted android , the run ifconfig lo command , get the output of information , mainly using Runtime.getRuntime (). exec () this method to get by reading the output stream .
tried many times , the result is empty , so I use the ifconfig lo adb shell in command , the output value is found .
My question is :
1. Why has the shell output , but I can not get it in their own way ? Is there any way much they do ?
2. My execRootCmd method, do the r.exec ("exit"); This row will be reported without permission exception, which is Mani ?
Thx in advance-v-
The main method is as follows:
// execute cmd
protected static Vector<String> execRootCmd(String paramString)
{
Vector<String> localVector = new Vector<String>();
DataInputStream dis = null;
Runtime r = Runtime.getRuntime();
try
{
r.exec("su"); // get root
StringBuilder sb = new StringBuilder();
Process p = r.exec(paramString);
InputStream input = p.getInputStream();
dis = new DataInputStream(input);
String content = null;
while ((content = dis.readLine()) != null)
{
sb.append(content).append("\n");
}
// r.exec("exit");
Log.i("UERY", "sb = " + sb.toString());
localVector.add(sb.toString());
}
catch (IOException e)
{
e.printStackTrace();
}
finally
{
if (dis != null)
{
try
{
dis.close();
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
return localVector;
}
------ Solution ------------------------------------- -------
based source development , you can compile the words:
1, in Android.mk add LOCAL_CERTIFICATE: = platform;
2, in AndroidManifest.xml add androidSharedUserId = "android.uid.system"
try to increase system permissions
------ Solution ------------------------------- -------------
Android seems to have a special command called NetCfg
------ Solution --------------- -----------------------------
may be your order wrong , I have encountered these problems, I is the output logs, the last time I have to thank the adb three letters,
This is the authority in question , hoping to help you live .
------ eference ------------------------ ---------------
Thank you buddy , increasing system permissions later, you can output the content.
there is a problem, why have content output with ifconfig eth0 with ifconfig eth0 192.168.22.56 IP settings set correctly so that it can not be set up before I run su, without being given full say , thank you.
------ eference --------------------------------------- < br> The next small roof
------ eference ---------------------------------- -----
Android in the command line, how to set up IP?
have studied before you, answer,
Bangding !
------ eference --------------------------------------- < br>
Thank you upstairs , the next day and then a small top .
------ eference --------------------------------------- < br>
command should be written on , and I run in the shell can be set up, a great possibility that you said authority, the command you want to run linux , android 's su permissions may still not enough.
netcfg can be used to see , but the real settings or to use ifconfig , right ?
------ eference --------------------------------------- < br> you do not know if the problem is how to solve it last ? I have encountered a similar situation with the landlord
没有评论:
发表评论