Original address: http://blog.sina.com.cn/s/blog_4c277ad30100yfqo.html
Customer needs to increase the size of the mobile phone read
So I found two methods. The first: Call Getwindowmanager () through the activity reference but my client has no interface so use another method: just pass in the context reference to method one://Get through WindowManager, This method is the usual method, passed in activitydisplaymetrics dm = new Displaymetrics (); Activity.getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM); System.out.println ("Heigth:" + dm.heightpixels); System.out.println ("width:" + dm.widthpixels); Method two//through resources get displaymetrics DM2 = Getresources (). Getdisplaymetrics (); System.out.println ("heigth2:" + dm2.heightpixels); System.out.println ("width2:" + dm2.widthpixels); Gets the default resolution of the screen display display = Getwindowmanager (). Getdefaultdisplay (); System.out.println ("Width-display:" + display.getwidth ()); System.out.println ("Heigth-display:" + display.getheight ());
(turn) No activity to get screen size