Public class androidtest extends activity {<br/> Private Static string tag = "androidtest"; </P> <p> private textview textview1; </P> <p> // class for obtaining the cell phone screen resolution <br/> private displaymetrics DM; </P> <p> @ override <br/> Public void oncreate (bundle savedinstancestate) {<br/> super. oncreate (savedinstancestate); <br/> setcontentview (R. layout. main); </P> <p> // obtain the textview in the layout <br/> textview1 = (textview) findviewbyid (R. id. hello); </P> <p> // method 1 Android gets the screen width and height <br/> int screenwidth; <br/> int screenheight; </P> <p> windowmanager = getwindowmanager (); <br/> display = windowmanager. getdefadisplay display (); <br/> screenwidth = display. getwidth (); <br/> screenheight = display. getheight (); </P> <p> log. D (TAG, "screenwidth:" + screenwidth); <br/> log. D (TAG, "screenheight:" + screenheight); </P> <p> // method 2 <br/> dm = new displaymetrics (); <br/> getwindowmanager (). getdefadisplay display (). getmetrics (DM); </P> <p> // The unit of pixels for obtaining the broadband and height of the mobile phone is PX. <br/> string STR = "Method 1: Mobile Phone screen resolution: "+ screenwidth <br/> +" * "+ screenheight + <br/>"/n method 2 cell phone screen resolution: "+ DM. widthpixels <br/> + "*" + DM. heightpixels; <br/> textview1.settext (STR); </P> <p >}< br/>}