Hello everyone
Recent brother wanted android, the command runs ifconfig lo get information output, 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 command, the output value is found.
My question is:
1 Why shell there is output, but I do not get their own way? We greatly what way?
2 My execRootCmd method execution to r.exec ("exit"); This row will be reported without permission exception, which is Mani?
Thx in advance-v-
Main methods used are as follows:
/ / Execute cmd
protected static VectorexecRootCmd (String paramString)
{
VectorlocalVector = new Vector ();
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;
}
<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Based on source development, you can compile the words:
An increase in LOCAL_CERTIFICATE in Android.mk: = platform;
2, increasing androidSharedUserId = "android.uid.system"
in the AndroidManifest.xml
Try to increase system privileges
Reply:
Thank you, buddy, later increased system privileges, you can output content.
There is a problem, why have content output ifconfig eth0 with ifconfig eth0 192.168.22.56 IP settings so it really can not be set, I performed before setting su, not being given the full say, thank you.
Reply:
The next day a small top
Reply:
Android How to set the IP on the command line?
Have studied it, answer,
Bangding!
Reply:
Thank you upstairs, and then the next day a small roof.
Reply:
Android seems to have a special command called NetCfg
Reply:
Your orders may be wrong, I have encountered these problems, I is the output log, last time I have to thank the adb three letters,
In this is a permissions issue, I hope to help you live.
Reply:
Command should be written to, and I run in the shell can be set up, a great possibility that you said permission problem, you want to run linux command, su android permissions may still not be enough.
netcfg can be used to view, but really do need to set ifconfig, right?
Reply:
Finally, you do not know what the problem is how to solve it? I have encountered similar situations with the landlord
No comments:
Post a Comment