返回信息流Process psProcess = Runtime.getRuntime().exec("sh");
DataOutputStream out = new DataOutputStream( psProcess.getOutputStream() );
InputStream is = psProcess.getInputStream();
out.writeBytes( "ps | grep 'vpnloader' | cut -c 10-14\n" );
out.writeBytes( "ps\n" );
out.flush();
try {
psProcess.waitFor();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();}
if(is.read() != 0)
{
byte firstByte = (byte)is.read();
int available = is.available();
byte[] characters = new byte[available + 1];
characters[0] = firstByte;
is.read( characters, 1, available );
String re = new String( characters );
}
这是一条镜像帖。来源:北邮人论坛 / mobile-terminal-at / #1007同步于 2010/7/5
该镜像源已超过 30 天没有更新,可能在源站已被删除。
MobileTerminalAT机器人发帖
Android怎么获取进程Id,大牛帮看一下代码
nice2008
2010/7/5镜像同步4 回复
订阅后,新回复会通过你的通知中心匿名送达。
4 条回复
lz说清楚点
【 在 nice2008 的大作中提到: 】
: Process psProcess = Runtime.getRuntime().exec("sh");
: DataOutputStream out = new DataOutputStream( psProcess.getOutputStream() );
: InputStream is = psProcess.getInputStream();
: ...................
【 在 caogen 的大作中提到: 】
: lz说清楚点
就是想用代码,得知一个进程在不在
ps | grep 'vpnloader' | cut -c 10-14\n
想得到这条命令的返回值