Get Android Device CPU Information Programmatically

How to check & show processor name,model number,CPU architecture adn implementer number in android .

Android mobile phone device cpu details are more expend then it loots like. Every cpu also known as Central processing unit contain multiple electronic slots. So in this tutorial we are going to get and display all the most important CPU factor like processor name, rev, model name, BogoMIPS, features, fastmult, cpu implementer, cpu architecture, cpu variant, cpu part etc. So here is the complete step by step  tutorial for Get Android Device CPU Information Programmatically .

android-project-download-code-button

How to Get Android Device CPU Information Programmatically.

Code for MainActivity.java file.

package com.android_examples.getcpu_info_android_exmplescom;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import java.io.IOException;
import java.io.InputStream;

public class MainActivity extends AppCompatActivity {

    TextView textView ;
    ProcessBuilder processBuilder;
    String Holder = "";
    String[] DATA = {"/system/bin/cat", "/proc/cpuinfo"};
    InputStream inputStream;
    Process process ;
    byte[] byteArry ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        textView = (TextView)findViewById(R.id.textView);

        byteArry = new byte[1024];

        try{
            processBuilder = new ProcessBuilder(DATA);

            process = processBuilder.start();

            inputStream = process.getInputStream();

            while(inputStream.read(byteArry) != -1){

                Holder = Holder + new String(byteArry);
            }

            inputStream.close();

        } catch(IOException ex){

            ex.printStackTrace();
        }

        textView.setText(Holder);
    }
}

Code for activity_main.xml layout file.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/activity_main"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin"
    tools:context="com.android_examples.getcpu_info_android_exmplescom.MainActivity"
    android:orientation="vertical"
    android:background="#FFF3E0">

    <ScrollView
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        >
    <LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical">

    <TextView
        android:text="CPU Information Display Here"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:id="@+id/textView"
        android:textColor="#000000"
        android:textSize="25dp"
        android:gravity="left"/>

    </LinearLayout>
    </ScrollView>

</LinearLayout>

Screenshot:

Get Android Device CPU Information Programmatically

Click here to download Get Android Device CPU Information Programmatically project with source code.

Leave a Reply

Your email address will not be published. Required fields are marked *