FAU Android

FAU's local android experts!

Determining your Device’s Info in Java

Posted by Charles Norona August - 25 - 2010 - Wednesday Comments Off

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.

Best practices and guidelines for writing efficient, well-designed Java programs

Posted by Georgiana Carvalho May - 19 - 2010 - Wednesday Comments Off
You must watch this video: Write Essay

This section covered several practices and guidelines for writing efficient, well-designed Java applications, specifically for the Android platform.

These guidelines are not only for improving the efficiency and speed of an application but also for making it more reliable, robust (less error prone and more secure), reusable and maintainable. 

To view the material covered in class please see Java – Best Practices.

To view the class recording see: Part 1 and Part 2.

References:

  1. Effective Java, Joshua Bloch, Prentice Hall, 2008 (ISBN-10: 0321356683)
  2. Best practices for coding your Android applications: http://developer.android.com/guide/practices/design/performance.html
zp8497586rq