-1

I want to get pixels in nubia z7 mini,whose system is android 4.4.2,but i failed. my code is below:

 DisplayMetrics dm = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(dm);

    String strOpt = "PIXEL:" + 
           dm.widthPixels + " × " + dm.heightPixels;

I get is 320 * 569 ,but the pixel of my phone can't be that; then i print density,i found it is 1.0,i can't know why;

 context.getResources().getDisplayMetrics().density

where was my error???How to get the pixels in a cellphone???

djjowfy
  • 3
  • 2
  • Check this post: http://stackoverflow.com/questions/3166501/getting-the-screen-density-programmatically-in-android – Giridharan Feb 06 '15 at 07:08
  • If you need the actual lcd pixel density you can get it from the metrics.xdpi and metrics.ydpi properties for horizontal and vertical density respectively. – Giridharan Feb 06 '15 at 07:14

1 Answers1

0

You could also try accessing through the Display class.

Display display = getWindowManager().getDefaultDisplay();
Point size = new Point();
display.getSize(size);

String strOpt = "PIXEL:" + size.x + " × " + size.y;
Anfaje
  • 335
  • 4
  • 14