private static final String LOG_TAG = "DeviceInfoSettings";private static final String FILENAME_PROC_VERSION = "/proc/version";private String readLine(String filename) throws IOException {BufferedReader reader = new BufferedReader(new FileReader(filename), 256);try {return reader.readLine();} finally {reader.close();}}//内核版本private String getFormattedKernelVersion() {String procVersionStr;try {procVersionStr = readLine(FILENAME_PROC_VERSION);final String PROC_VERSION_REGEX ="\\w+\\s+" + /* ignore: Linux */"\\w+\\s+" + /* ignore: version */"([^\\s]+)\\s+" + /* group 1: 2.6.22-omap1 */"\\(([^\\s@]+(?:@[^\\s.]+)?)[^)]*\\)\\s+" + /* group 2: (xxxxxx@xxxxx.constant) */"\\((?:[^(]*\\([^)]*\\))?[^)]*\\)\\s+" + /* ignore: (gcc ..) */"([^\\s]+)\\s+" + /* group 3: #26 */"(?:PREEMPT\\s+)?" + /* ignore: PREEMPT (optional) */"(.+)"; /* group 4: date */Pattern p = Pattern.compile(PROC_VERSION_REGEX);Matcher m = p.matcher(procVersionStr);if (!m.matches()) {Log.e(LOG_TAG, "Regex did not match on /proc/version: " + procVersionStr);return "Unavailable";} else if (m.groupCount() < 4) {Log.e(LOG_TAG, "Regex match on /proc/version only returned " + m.groupCount()+ " groups");return "Unavailable";} else {return (new StringBuilder(m.group(1)).append("\n").append(m.group(2)).append(" ").append(m.group(3)).append("\n").append(m.group(4))).toString();}} catch (IOException e) {Log.e(LOG_TAG,"IO Exception when getting kernel version for Device Info screen",e);return "Unavailable";}}public void showIntroduceDialog(){ AlertDialog.Builder builder = new AlertDialog.Builder(this); builder.setTitle("系统信息"); StringBuilder sb = new StringBuilder(); sb.append("SDK版本信息:"+Build.VERSION.SDK+"\n\n"); sb.append("Android版本信息:"+android.os.Build.VERSION.RELEASE+"\n\n"); sb.append("内核版本信息:"+getFormattedKernelVersion()+"\n\n");builder.setMessage(sb.toString()); builder.setNegativeButton("确定", null); builder.create().show(); } 

更多相关文章

  1. Android(安卓)获取当前连接的WiFi信息
  2. Android-Android(安卓)API 版本判断
  3. 数据库版本升级降级
  4. Android(安卓)SDK 版本对应版本号
  5. Android系统的版本号与API的对应表
  6. Android电源信息
  7. android实现解析webservices
  8. android 获取rom名称和版本号
  9. Error:org.gradle.api.internal.tasks.DefaultTaskInputs$TaskIn

随机推荐

  1. PHP高并发高可用系统以及面试分析
  2. Python(十)文件操作
  3. Linux SRE 必经之路
  4. 怎么画人物的眼睛?画漫画人物的眼睛画法
  5. 探索 .NET Core的依赖注入
  6. Diem协会高管:Novi钱包如何修复全球支离破
  7. 完整版Java零基础自学教程+笔记+源码分享
  8. 2021年腾讯面试总结(已拿offer)
  9. 商城列表页和商品详情页
  10. 淘宝 NPM 镜像站切换新域名啦(转载)