Unlike iPhone, Android devices come with different hardware from different manufacturers. One important difference is the CPU architecture. Although almost all Android devices use ARM CPU, it comes with different versions, including armv5, armv5te, armv6, armv6 with VFP, armv7, armv7 with VFP, armv7 with neon etc.

Most of the time there’s no need for a developer to care about CPU types, but if you are developing CPU intensive apps, e.g. video player, video converter etc, you may want to optimize your code based on CPU types.

Retrieving CPU types on Android devices is actually quite simple. Android is based on Linux, and Linux /proc file system has provided an interface for users to get CPU information — /proc/cpuinfo. So to get the CPU information, you simply read this file. And read this file doesn’t require super user privilege.

To get the CPU info from command line, simple enter the command below,

adb shell                              (connect to your Android device shell)

cat /proc/cpuinfo               (read the CPU info)

If you want to get the CPU info programmatically, use the code below,

private String getInfo() {

    StringBuffer sb = new StringBuffer();

    sb.append("abi: ").append(Build.CPU_ABI).append("\n");

    if (new File("/proc/cpuinfo").exists()) {

        try {

            BufferedReader br = new BufferedReader(new FileReader(new File("/proc/cpuinfo")));

            String aLine;

            while ((aLine = br.readLine()) != null) {

                sb.append(aLine + "\n");

            }

            if (br != null) {

                br.close();

            }

        } catch (IOException e) {

            e.printStackTrace();

        } 

    }

    return sb.toString();

}

You can download the entire code from here or get it from my github repo here.
A sample output is as below,

It gives the process type, and features that are supported by it.

 

Leave a Reply

Your email address will not be published.

* Copy This Password *

* Type Or Paste Password Here *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Set your Twitter account name in your settings to use the TwitterBar Section.