Friday, February 10, 2012

How to programmatically figure out the screen resolution of android device?

This code will give you the screen resolution at run time.
The size of your application may differ due to the status and title bar.

@Override 
public void onCreate(Bundle icicle) { 
 WindowManager w = getWindowManager(); 
 Display d = w.getDefaultDisplay(); 

 int width = d.getWidth(); 
 int height = d.getHeight();
}

2 comments:

  1. Display.getWidth() and Display.getHeight deprecated in API13

    ReplyDelete
  2. Some important articles like ExoPlayer, Camera2API YouTube, AndroidJetpack and design patten related can add also here

    ReplyDelete