android获得手机cpu型号

  public boolean hasCompatibleCPU() {
        // If already checked return cached result

        String CPU_ABI = android.os.Build.CPU_ABI;
        Log.i("wyn_cpu","CPU_ABI = "+CPU_ABI);
        String CPU_ABI2 = "none";
        if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.FROYO) { // CPU_ABI2
            // since
            // 2.2
            try {
                CPU_ABI2 = (String) android.os.Build.class.getDeclaredField(
                        "CPU_ABI2").get(null);
                Log.i("wyn_cpu","2.2 CPU_ABI2 = "+CPU_ABI2);
            } catch (Exception e) {
                return false;
            }
        }

        if (CPU_ABI.equals("armeabi-v7a") || CPU_ABI2.equals("armeabi-v7a")) {
            return true;
        }

        try {
            FileReader fileReader = new FileReader("/proc/cpuinfo");
            BufferedReader br = new BufferedReader(fileReader);
            String line;
            while ((line = br.readLine()) != null) {
                if (line.contains("ARMv7")) {
                    Log.i("wyn_cpu","line.contains(\"ARMv7\") ");
                    return true;
                }

            }
            fileReader.close();
        } catch (IOException ex) {
            ex.printStackTrace();
            return false;
        }
        return false;
    }

你可能感兴趣的:(android)