使用了Root Tools 来招待命令。https://code.google.com/p/roottools/
代码如下:
private void answerRingingCall()
{
try
{
Command command = new Command(0, "input keyevent 5")
{
@Override
public void output(int id, String line)
{
Log.d(Tag, line);
}
};
RootTools.getShell(true).add(command).waitForFinish();
}
catch (InterruptedException e)
{
e.printStackTrace();
}
catch (IOException e)
{
e.printStackTrace();
}
catch (TimeoutException e)
{
e.printStackTrace();
}
catch (RootDeniedException e)
{
e.printStackTrace();
}
}