Reputation: 1104
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?
Upvotes: 0
Views: 1761
Reputation: 4323
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);
Upvotes: 0
Reputation: 3937
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+"");
Upvotes: 3
Reputation: 2032
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
Upvotes: 0