通过分析文件获取
代码
//获取CPU内核数 public int getCPUCoreCount() { class CpuFilter implements FileFilter { @Override public boolean accept(File pathname) { if(Pattern.matches("cpu[0-9]", pathname.getName())) { return true; } return false; } } try { File dir = new File("/sys/devices/system/cpu/"); File[] files = dir.listFiles(new CpuFilter()); return files.length; } catch(Exception e) { Log.d(TAG, "CPU Count: Failed."); e.printStackTrace(); return 1; } }