Android手机CPU信息获取

 public static String[] getCpuInfo() {
        String str1 = "/proc/cpuinfo";   
        String str2="";
        String[] cpuInfo={"",""};   
        String[] arrayOfString;   
        try {   
            FileReader fr = new FileReader(str1);   
            BufferedReader localBufferedReader = new BufferedReader(fr, 8192);   
            str2 = localBufferedReader.readLine();   
            arrayOfString = str2.split("\\s+");   
            for (int i = 2; i < arrayOfString.length; i++) {   
                cpuInfo[0] = cpuInfo[0] + arrayOfString[i] + " ";   
            }   
            str2 = localBufferedReader.readLine();   
            arrayOfString = str2.split("\\s+");   
            cpuInfo[1] += arrayOfString[2];   
            localBufferedReader.close();   
        } catch (IOException e) {
            e.printStackTrace();
        }
        return cpuInfo;   
    }
该方法可以获得android手机的cpu型号以及cpu的频率;在onCreate中调用;

你可能感兴趣的:(android)