Error getting window size on android: “The method getWindowManager is undefined”

前端 未结 6 2250
半阙折子戏
半阙折子戏 2020-12-18 20:08

I need to get the window height and the weight.
I have this in my code:

DisplayMetrics metrics = new DisplayMetrics();
getWindowManager().getDefaultDispl         


        
6条回答
  •  难免孤独
    2020-12-18 20:43

    Please check if you are calling above method in an activity class, or outside activity.

    For Wallpaper, this method is not availed to you to get height or width of window, you need to get width and height of available window by using surface.

提交回复
热议问题