How to detect system information like os or device type

后端 未结 7 2193
不思量自难忘°
不思量自难忘° 2020-11-27 11:17

The most important things I want to know are the device type, the OS version, if it has a hardware keyboard and maybe the screen resolution. but if you know other useful deb

7条回答
  •  离开以前
    2020-11-27 12:02

    For screen resolution:

    getWindow().getWindowManager().getDefaultDisplay().getWidth();
    getWindow().getWindowManager().getDefaultDisplay().getHeight();
    

    For hardware keyboard presence:

    boolean keyboardPresent = (getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS);
    

提交回复
热议问题