Android Get Screen dimensions from Service

后端 未结 4 2055
Happy的楠姐
Happy的楠姐 2021-02-02 08:35

I got the Screen Size by using the following from a activity,

Display display = getWindowManager().getDefaultDisplay();

But the same thing is n

4条回答
  •  孤街浪徒
    2021-02-02 08:51

    there totally is a way to obtain it from a service:

        WindowManager window = (WindowManager) getSystemService(Context.WINDOW_SERVICE); 
        Display display = window.getDefaultDisplay();
        int width = display.getWidth();
        int height = display.getHeight();
    

提交回复
热议问题