title: Android - Enable 4K Activity with 4K GLSurfaceView
body: <p>I'm upgrading my Android OpenGL app to run on my new 4K phone and am intending to have a fullscreen activity whose dimensions are both logically and physically 4K. However, without special-casing for 4K, I'm running into the evidently expected scenario that my activity is only 1080p in size and I wish to bump it up to 4K.</p>
  
  <p>I have followed the available documentation involving querying the display modes, which thankfully does enumerate both 1080p and 4K as available display modes. The pseudo code getBestDisplayModeId() below represents this step, which I consider to be functioning accurately. This function can be assumed to correctly return the display mode id of the 4K display mode. I then set the preferredDisplayModeId in the LayoutParams for the window to that optimal display mode id and use setAttributes() to hopefully apply it to the window.</p>
  
  <p>This is executed during the onCreate() for my fullscreen Activity. Note that the activity was created via the fullscreen activity wizard in Android Studio and it essentially contains just a GLSurfaceView and associated Renderer (the typical OpenGL setup).</p>
  
  <p>My (GL) Renderer class was temporarily modified (for debugging purposes) to display a Toast (via IPC), showing its dimensions whenever its onSurfaceChanged() overridden method is called. The Toast is always reporting that the dimensions are 1080p, rather than the intended 4K.</p>
  
  <p>How can I correctly apply the preferredDisplayModeId and then get an Activity/View/GLSurfaceView that is truly the intended 4K size? </p>
  
  <pre><code>int getBestDisplayModeId()
  {
      // 1. query available display modes for display 0 via DisplayManager
      // 2. return display mode corresponding to the highest resolution 
  }
  
  FullscreenActivity.onCreate()
  {
      Window w = getWindow();
      WindowManager.LayoutParams p = w.getAttributes();
      p.preferredDisplayModeId = getBestDisplayModeId(); // get 4K id
      w.setAttributes(p); // set 4K resolution
  
      // when does the switch to 4K occur? 
  
      mGLView = new MyGLSurfaceView();
      setContentView(mGLView);
  }
  
  
  MyRenderer.onSurfaceChanged(int w, int h)
  {
       // only shows 1080p resolution, never 4K
  }
  </code></pre>