How to get the number of cores of an android device

后端 未结 8 2095
挽巷
挽巷 2020-12-04 21:44

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

8条回答
  •  情深已故
    2020-12-04 22:25

    You can try this method to get number of core.

     private int getNumOfCores()
          {
            try
            {
              int i = new File("/sys/devices/system/cpu/").listFiles(new FileFilter()
              {
                public boolean accept(File params)
                {
                  return Pattern.matches("cpu[0-9]", params.getName());
                }
              }).length;
              return i;
            }
            catch (Exception e)
            {
                  e.printstacktrace();
            }
            return 1;
          }
    

提交回复
热议问题