软件编程
位置:首页>> 软件编程>> Android编程>> 详解Android获取系统内核版本的方法与实现代码

详解Android获取系统内核版本的方法与实现代码

作者:lqh  发布时间:2023-11-25 14:51:59 

标签:Android,内核版本

Android获取系统内核版本的方法

                这里主要实现获取Android Linux 内核的版本号,网上关于这类文章不是很多,这里记录下,希望能帮助到大家,

实现代码:


public static String getKernelVersion() {
 String kernelVersion = "";
 InputStream inputStream = null;
 try {
   inputStream = new FileInputStream("/proc/version");
 } catch (FileNotFoundException e) {
   e.printStackTrace();
   return kernelVersion;
 }
 BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream), 8 * 1024);
 String info = "";
 String line = "";
 try {
   while ((line = bufferedReader.readLine()) != null) {
     info += line;
   }
 } catch (IOException e) {
   e.printStackTrace();
 } finally {
   try {
     bufferedReader.close();
     inputStream.close();
   } catch (IOException e) {
     e.printStackTrace();
   }
 }

try {
   if (info != "") {
     final String keyword = "version ";
     int index = info.indexOf(keyword);
     line = info.substring(index + keyword.length());
     index = line.indexOf(" ");
     kernelVersion = line.substring(0, index);
   }
 } catch (IndexOutOfBoundsException e) {
   e.printStackTrace();
 }

return kernelVersion;
}

来源:http://blog.csdn.net/singwhatiwanna/article/details/17343139

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com