取得android中linux的内核版本号
2010-05-26 06:06:00 来源:WEB开发网tv01 = (TextView)findViewById(R.id.TextView01);
Process process = null;
try {
process = Runtime.getRuntime().exec("cat /proc/version");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
//get the output line
InputStream outs = process.getInputStream();
InputStreamReader isrout = new InputStreamReader(outs);
BufferedReader brout = new BufferedReader(isrout,8*1024);
String result = "";
String line;
// get the whole standard output string
try {
while ( (line = brout.readLine()) != null) {
result += line;
//result += " ";
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if( result != "" ) {
String Keyword = "version ";
int index = result.indexOf(Keyword);
Log.v("Tom", result);
line = result.substring(index + Keyword.length());
index = line.indexOf(" ");
tv01.setText(line.substring(0,index));
}
android sdk 2.2下的模拟器得到的结果是:
2.6.29-00261-g0097074-dirty
更多精彩
赞助商链接