博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
android获取手机cpu是单核还是多核的方法
阅读量:4342 次
发布时间:2019-06-07

本文共 1210 字,大约阅读时间需要 4 分钟。

/** * Gets the number of cores available in this device, across all processors. * Requires: Ability to peruse the filesystem at "/sys/devices/system/cpu" * @return The number of cores, or 1 if failed to get result */private int getNumCores() {    //Private Class to display only CPU devices in the directory listing    class CpuFilter implements FileFilter {        @Override        public boolean accept(File pathname) {            //Check if filename is "cpu", followed by a single digit number            if(Pattern.matches("cpu[0-9]", pathname.getName())) {                return true;            }            return false;        }          }    try {        //Get directory containing CPU info        File dir = new File("/sys/devices/system/cpu/");        //Filter to only list the devices we care about        File[] files = dir.listFiles(new CpuFilter());        //Return the number of cores (virtual CPU devices)        return files.length;    } catch(Exception e) {        //Default to return 1 core        return 1;    }}

参考http://stackoverflow.com/questions/7962155/how-can-you-detect-a-dual-core-cpu-on-an-android-device-from-code

 

转载于:https://www.cnblogs.com/likwo/archive/2013/02/21/2920675.html

你可能感兴趣的文章
设计原理+设计模式
查看>>
tomcat 7服务器跨域问题解决
查看>>
前台实现ajax 需注意的地方
查看>>
Jenkins安装配置
查看>>
个人工作总结05(第二阶段)
查看>>
Java clone() 浅拷贝 深拷贝
查看>>
深入理解Java虚拟机&运行时数据区
查看>>
02-环境搭建
查看>>
spring第二冲刺阶段第七天
查看>>
搜索框键盘抬起事件2
查看>>
阿里百川SDK初始化失败 错误码是203
查看>>
透析Java本质-谁创建了对象,this是什么
查看>>
BFS和DFS的java实现
查看>>
关于jquery中prev()和next()的用法
查看>>
一、 kettle开发、上线常见问题以及防错规范步骤
查看>>
eclipse没有server选项
查看>>
CRC码计算及校验原理的最通俗诠释
查看>>
使用Gitbook来编写你的Api文档
查看>>
jquery扩展 $.fn
查看>>
Markdown指南
查看>>