public
static
boolean
runRootCommand(
String
command)
{
Process
process =
null
;
DataOutputStream
os =
null
;
try
{
process =
Runtime
.getRuntime
(
)
.exec
(
"su
"
)
;
os =
new
DataOutputStream
(
process.getOutputStream
(
)
)
;
os.writeBytes
(
command+
"/n
"
)
;
os.writeBytes
(
"exit/n
"
)
;
os.flush
(
)
;
process.waitFor
(
)
;
}
catc
h
(
Exception
e)
{
Log.d
(
"*** DEBUG ***"
, "Unexpected error - Here is what I know: "
+
e.getMessage
(
)
)
;
return
false
;
}
finally
{
try
{
if
(
os !=
null
)
{
os.close
(
)
;
}
process.destroy
(
)
;
}
catch
(
Exception
e)
{
// nothing
}
}
return
true
;
}
}
编写使用root权限的android应用程序
最新推荐文章于 2021-05-25 23:03:31 发布