The device detection mini app
To make this app, create a new project and call it Device Detection. Delete the default Hello world! widget. Drag Button onto the top of the screen and set its onClick property to detectDevice. We will code this method in a minute.
Drag two LargeText widgets onto the layout and set their id properties to txtOrientation and txtResolution, respectively. You should now have a layout that looks something like this:

Add the following members just after the MainActivity class declaration to hold references to our two TextView widgets:
private TextView txtOrientation; private TextView txtResolution;
Now, in the onCreate method of MainActivity, just after the call to setContentView, add this code:
// Get a reference to our TextView widgets txtOrientation = (TextView) findViewById(R.id.txtOrientation); txtResolution = (TextView) findViewById(R.id.txtResolution);
After onCreate, add the method that handles our button click and runs our detection code:
public void detectDevice...