Retrieving the user-agent for Tablet | Community
Skip to main content
September 10, 2020
Solved

Retrieving the user-agent for Tablet

  • September 10, 2020
  • 1 reply
  • 1727 views

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);

}

 

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Vijayalakshmi_S

Hi @v1101

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.

1 reply

Vijayalakshmi_S
Vijayalakshmi_SAccepted solution
September 10, 2020

Hi @v1101

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.

v1101Author
September 10, 2020
@vijayalakshmi_s - Thanks for your expedited response. We have an image component. In that component, authors will upload the image for desktop only. Based on the user-agent, i.e for Tablet & Mobile, we need to apply the renditions (Adding path at the suffix for the selected image URL) and based on the user-agent, will show the appropriate image for Tablet and Mobile devices.