How to get screen display metrics in application class

前端 未结 6 559
自闭症患者
自闭症患者 2020-11-30 10:38

If I put this in some activity class it works perfectly but, when I put it in my App class the method getWindowManager() can not be found. Is there some way to

6条回答
  •  北荒
    北荒 (楼主)
    2020-11-30 11:20

    Try this:

    Display display = getWindowManager().getDefaultDisplay();
    Log.e("", "" + display.getHeight() + " " + display.getWidth());
    

提交回复
热议问题