Home » Android » How to get the processor number on android

How to get the processor number on android

Posted by: admin June 15, 2020 Leave a comment

Questions:

Hi all, I want to get the processor number on android. can I do that like as follow:

int processporNum =  sysconf(_SC_NPROCESSORS_CONF);

but everytime the return value is 1 on some of my phones, so i not sure this methold is right .is there anyother api can get this info

How to&Answers:

you can run

Runtime.getRuntime().availableProcessors()

Answer:

I see you’re using native code.

So read file /proc/cpuinfo and interpret is accordingly.
It looks something like this:

Processor   : ARMv7 Processor rev 2 (v7l)
BogoMIPS    : 162.83
Features    : swp half thumb fastmult vfp edsp thumbee neon 
CPU implementer : 0x51
CPU architecture: 7
CPU variant : 0x0
CPU part    : 0x00f
CPU revision    : 2
Hardware    : htcleo
Revision    : 0000
Serial      : 0000000000000000