WEB开发网
开发学院手机开发Android 开发 取得android中linux的内核版本号 阅读

取得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 (IOExcepti

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

Tags:取得 android linux

编辑录入:coldstar [复制链接] [打 印]
赞助商链接