0

I am talking about Device resolution not screen size.

I saw many previous questions' answers that was something like 320 x480, i think this is screen size. Correct me if i am wrong.

For example, Samsung Galaxy Note Resolution is 1280 x 800 pixel.

How do i get this value in java programming?

Alan Lai
  • 1,094
  • 7
  • 18
  • 41

4 Answers4

3

try this

Display display = getWindowManager().getDefaultDisplay(); 
            int width = display.getWidth();  // deprecated
            int height = display.getHeight();  // deprecated
            Log.d("hai",width+"");
            Log.d("hai",height+"");
            DisplayMetrics dm = new DisplayMetrics();
            getWindowManager().getDefaultDisplay().getMetrics(dm);
            double x = Math.pow(width/dm.xdpi,2);
            double y = Math.pow(height/dm.ydpi,2);
            double screenInches = Math.sqrt(x+y);
            Log.d("hai","Screen inches : " + screenInches+"");
Jackson Chengalai
  • 3,907
  • 1
  • 24
  • 39
0

800x1280px is the resolution according to http://www.phonegg.com/compare/27/Samsung-I9100-Galaxy-S-II-vs-Samsung-Galaxy-Note.html

this question should tell you how to get the resolution. Get screen dimensions in pixels

Community
  • 1
  • 1
Klee
  • 2,022
  • 3
  • 23
  • 32
0

Use this simple code to get the resolution.

Display display = getWindowManager().getDefaultDisplay(); 
        int  width = display.getWidth();
        int height= display.getHeight();
        TextView w=(TextView)findViewById(R.id.textView2);
        w.setText(""+width);
        TextView h=(TextView)findViewById(R.id.textView4);
        h.setText(""+height);
Naresh Sharma
  • 4,323
  • 7
  • 48
  • 68
0

Try this example on how to get information about the device display.

CMA
  • 2,758
  • 5
  • 28
  • 40