get Cpu String - Android Hardware

Android examples for Hardware:CPU Information

Description

get Cpu String

Demo Code


//package com.java2s;

import java.io.IOException;
import java.io.RandomAccessFile;

import android.os.Build;

public class Main {
    public static String getCpuString() {
        if (Build.CPU_ABI.equalsIgnoreCase("x86")) {
            return "Intel";
        }//from  w ww .j  av a 2s  . c  o  m
        String strInfo = "";
        try {
            byte[] bs = new byte[1024];
            RandomAccessFile reader = new RandomAccessFile("/proc/cpuinfo",
                    "r");
            reader.read(bs);
            String ret = new String(bs);
            int index = ret.indexOf(0);
            if (index != -1) {
                strInfo = ret.substring(0, index);
            } else {
                strInfo = ret;
            }
        } catch (IOException ex) {
            ex.printStackTrace();
        }

        return strInfo;
    }
}

Related Tutorials