Retrieving the user-agent for Tablet

Avatar

Avatar

viki1101

Avatar

viki1101

viki1101

10-09-2020

Hello Community - We are detecting the user-agent(Desktop/Mobile/Tablet) using WCMUsePojo and based on the user-agent, we are showing the appropriate content in HTL. It is working only for Mobile but when we use "Tablet", it is not working. Can you let me how to retrieve it for tablet?

 

public void activate() throws Exception {

setMobile(getRequest().getHeader("User-Agent").indexOf("Mobile") != -1 ? Boolean.TRUE: Boolean.FALSE);

}

 

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar

Vijayalakshmi_S

MVP

Avatar

Vijayalakshmi_S

MVP

Vijayalakshmi_S
MVP

10-09-2020

Hi @viki1101

Unlike Mobile, there is no generic name for Tablets in User-Agent Header. For iPad, you can make use of the string "iPad"

Below site has the list of all possible User-Agent values for Tablet. If you have specific list of supported devices, you can write condition accordingly

As an alternative, there are several other options available for device specific logic.

Could you please brief about your component functionality.

Answers (0)