Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

How to Get Device Information in Android

DZone's Guide to

How to Get Device Information in Android

Learn how to uniquely identify users by using parts of device information on Android.

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

The following code snippet will get the device detailed information in Android.

public class DashboardActivity extends Activity { 

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        String  details =  "VERSION.RELEASE : "+Build.VERSION.RELEASE
            +"\nVERSION.INCREMENTAL : "+Build.VERSION.INCREMENTAL
            +"\nVERSION.SDK.NUMBER : "+Build.VERSION.SDK_INT
            +"\nBOARD : "+Build.BOARD
            +"\nBOOTLOADER : "+Build.BOOTLOADER
            +"\nBRAND : "+Build.BRAND
            +"\nCPU_ABI : "+Build.CPU_ABI
            +"\nCPU_ABI2 : "+Build.CPU_ABI2
            +"\nDISPLAY : "+Build.DISPLAY
            +"\nFINGERPRINT : "+Build.FINGERPRINT
            +"\nHARDWARE : "+Build.HARDWARE
            +"\nHOST : "+Build.HOST
            +"\nID : "+Build.ID
            +"\nMANUFACTURER : "+Build.MANUFACTURER
            +"\nMODEL : "+Build.MODEL
            +"\nPRODUCT : "+Build.PRODUCT
            +"\nSERIAL : "+Build.SERIAL
            +"\nTAGS : "+Build.TAGS
            +"\nTIME : "+Build.TIME
            +"\nTYPE : "+Build.TYPE
            +"\nUNKNOWN : "+Build.UNKNOWN
            +"\nUSER : "+Build.USER;

           TextView textView = new TextView();

           textView.setText(details);
           setContentView(textView);
        }
}

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:
java ,android ,snippets

Published at DZone with permission of Nilanchala Panigrahy, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}