Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vaadin-14: checking if client is a mobile device

i am developing a webapp and i want to separate UIs for desktops and mobile devices, so i want to check wether the client using my app is a mobile device or not.

I tried to look online for official documentation or vaadin forum , but i couldn't find any useful information, since almost all of the solutions proposed in those answers are not implementable any more (the methods were removed).

like image 203
Federico Andreoli Avatar asked Nov 30 '25 16:11

Federico Andreoli


1 Answers

You can use VaadinSession.getCurrent().getBrowser() to see if your client is a phone or not.

public  boolean isMobileDevice() {
    WebBrowser webBrowser = VaadinSession.getCurrent().getBrowser();
    return webBrowser.isAndroid() || webBrowser.isIPhone() || webBrowser.isWindowsPhone();
}
like image 114
Mehdi Javan Avatar answered Dec 02 '25 06:12

Mehdi Javan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!