Detecting Device Type in a web application

前端 未结 8 2337
隐瞒了意图╮
隐瞒了意图╮ 2020-11-28 08:48

We have a Java based application where in we want to detect the device type(mobile or desktop) for the device that is sending the request.

How is it possible?

8条回答
  •  长情又很酷
    2020-11-28 09:16

    You can try to use Spring Mobile. There are convenient classes to solve that.

    Device currentDevice = DeviceUtils.getCurrentDevice(servletRequest);
    if(currentDevice.isMobile()) { /* Mobile */ }
    if(currentDevice.isTablet()) { /* Tablet */ }
    if(currentDevice.isNormal()) { /* Desktop */ }
    

提交回复
热议问题