FAU Android

FAU's local android experts!

Determining your Device’s Info in Java

Posted by Charles Norona August - 25 - 2010 - Wednesday

Sooner or later there will come an instance where one is developing applications on Android and will have to provide some kind of mechanism for making their applications compatible with different hardware platforms. Reasons for using this class can vary from ensuring that the user interface looks proper across different resolutions, changing parameters within algorithms in order to optimize performance, etc. Fortunately, the Android engineers have provided developers the android.os.Build class which can be used to acquire this information. An example of its use is depicted below:


private String TAG = "SSLA";

...

//Determine the local device info for compatibility
Log.i(TAG, "Device information: \n" +
"Board: " + Build.BOARD + "\n" +
"Brand: " + Build.BRAND + "\n" +
"CPU: " + Build.CPU_ABI + "\n" +
"Device: " + Build.DEVICE + "\n" +
"Display: " + Build.DISPLAY + "\n" +
"Fingerprint: " + Build.FINGERPRINT + "\n" +
"Host: " + Build.HOST + "\n" +
"ID: " + Build.ID + "\n" +
"Manufacturer: " + Build.MANUFACTURER + "\n" +
"Model: " + Build.MODEL + "\n" +
"Product: " + Build.PRODUCT + "\n" +
"Tags: " + Build.TAGS + "\n" +
"Time: " + Build.TIME + "\n" +
"Type: " + Build.TYPE + "\n" +
"User: " + Build.USER);

//Example application of using the Build class.
if ((Build.MODEL.equals("T-Mobile G1"))
|| (Build.MODEL.equals("HTC Dream"))
|| (Build.MODEL.equals("Era G1")))//T-Mobile G1 or HTC Dream
slideRate = 6;
else if (Build.MODEL.equals("Nexus One"))//Google Nexus One
slideRate = 4;
else//Default sliding background rate.
slideRate = 4;

The giant log statement produces the following output on the DDMS Logcat:

Output showing use of Build class.

Comments are closed.