How to get screen display metrics in application class

前端 未结 6 542
自闭症患者
自闭症患者 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:29

    Here, Context.getResource()

    DisplayMetrics dm = getResources().getDisplayMetrics(); 
    int densityDpi = dm.densityDpi;

提交回复
热议问题