Directly paste Code
Tvmodel.settext (Android.os.Build.MODEL)/Mobile phone model
Get screen density (Method 1)
int screenWidth1 = Getactivity (). Getwindowmanager (). Getdefaultdisplay (). GetWidth (); Screen width (pixels, such as: 480px)
int screenHeight1 = Getactivity (). Getwindowmanager (). Getdefaultdisplay (). GetHeight (); High screen (pixel, such as: 800p)
Tvscreenheight1.settext (screenHeight1 + "px");
Tvscreenwidth1.settext (screenWidth1 + "px");
Get screen density (Method 2)
Displaymetrics dm2 = Getresources (). Getdisplaymetrics ();
float density = dm2.density; Screen density (pixel scale: 0.75/1.0/1.5/2.0)
int densitydpi = dm2.densitydpi; Screen density (pixels per inch: 120/160/240/320)
float xdpi = dm2.xdpi;
float ydpi = dm2.ydpi;
int screenWidth2 = Dm2.widthpixels; Screen width (pixels, such as: 480px)
int screenHeight2 = Dm2.heightpixels; High screen (pixel, such as: 800px)
Tvscreenheight2.settext (screenHeight2 + "px");
Tvscreenwidth2.settext (screenWidth2 + "px");
Tvscreendensity2.settext (density + "");
Tvscreendensitydpi2.settext (densitydpi + "");
Get screen density (Method 3)
Displaymetrics dm3 = new Displaymetrics ();
Getactivity (). Getwindowmanager (). Getdefaultdisplay (). Getmetrics (DM3);
density = dm3.density; Screen density (pixel scale: 0.75/1.0/1.5/2.0)
densitydpi = dm3.densitydpi; Screen density (pixels per inch: 120/160/240/320)
xdpi = dm3.xdpi;
ydpi = dm3.ydpi;
Tvscreendensity3.settext (density + "");
Tvscreendensitydpi3.settext (densitydpi + "");
int screenWidth3 = Dm3.widthpixels; Screen width (px, such as: 480px)
int screenHeight3 = Dm3.heightpixels; High screen (PX, such as: 800px)
Tvscreenheight3.settext (screenHeight3 + "px");
Tvscreenwidth3.settext (screenWidth3 + "px");
float Screenwidthdip = (dm3.widthpixels/density); Screen width (dip, such as: 320dip)
float Screenheightdip = (dm3.heightpixels/density); Screen width (dip, such as: 533dip)
Tvscreenheight4.settext (Screenheightdip + "dip");
Tvscreenwidth4.settext (Screenwidthdip + "dip");