5

I execute /proc/cpuinfo to get the details of CPU in android device using the below code.

        try {
            Process proc = Runtime.getRuntime().exec("cat /proc/cpuinfo");
            InputStream is = proc.getInputStream();
            TextView tv = (TextView)rootView.findViewById(R.id.textView1);
            tv.setText(getStringFromInputStream(is));
        } 
        catch (IOException e) {
            Log.e("TAG", "------ getCpuInfo " + e.getMessage());
        }

Within this it also returns Hardware Name. The Hardware name which I get is not in proper readable Format. I have tested this in various devices like Samsung Note 3, Micromax Canvas Doodle A111, Micromax Turbo A250.

This is what I get in these devices respectively:

  • Samsung EXYNOS5420 : (but I need this name Samsung Exynos Octa 5420 )
  • QRD MSM8625Q EVBD : (need name Qualcomm Snapdragon 200 )
  • MT6589 : ( MediaTek MT6589 )

How can I overcome this, Please Help !!!

1

1 Answer 1

2

It seems a bit unclear to me if that you CPU capabilities or device information in general, but anyway...

Android provides a nice little class called Build which gets you quite a bit of information directly via the static fields of the class. This class provides a lot of device-level information as shown below:

Taken directly from my HTC One M8 (some fields omitted):

Build.BOARD: MSM8974
Build.BOOTLOADER: 3.19.0.0000
Build.BRAND: htc
Build.DEVICE: htc_m8
Build.DISPLAY: cm_m8-userdebug 5.1.1 LMY47V 47d6aee9c3 test-keys
Build.HARDWARE: qcom
Build.MANUFACTURER: htc
Build.MODEL: One M8
Build.PRODUCT: cm_m8

From the looks of it Build.BRAND + " " + Build.MODEL looks like what you want.

Whilst the docs doesn't guarantee any standardization for any field, this is likely to be better than calling Runtime.exec("cat /proc/cpuinfo") and parsing from there.

If CPU level capabilities is what you want, you can try doing from native code using android cpufeatures library, calling the function:

uint64_t android_getCpuFeatures();

to get a int containing many CPU feature flags.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, Could u pls explain me more about using native code, I have never done native programming !
@vivekwarde Go look at tutorials on Android NDK. The conventions are similar to JNI but android provides it's own build tools.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.