I was looking to determine(or count) the number of cores in the embedded processor of android device.
I tried using /proc/cpuinfo, but it is not return
/proc/cpuinfo
Nice and simple solution in kotlin:
fun getCPUCoreNum(): Int { val pattern = Pattern.compile("cpu[0-9]+") return Math.max( File("/sys/devices/system/cpu/") .walk() .maxDepth(1) .count { pattern.matcher(it.name).matches() }, Runtime.getRuntime().availableProcessors() ) }