I have this simple utility code to check for browser User-Agent:
public class UserAgentHelper {
public static boolean isMobile(){
String userAgent = getUserAgent();
return userAgent.contains("ipad");
}
public static boolean isAndroid(){
return getUserAgent().contains("android");
}
public static native String getUserAgent() /*-{
return navigator.userAgent.toLowerCase();
}-*/;
}
I need to check if the browser is mobile or desktop. That is the main point. I'm starting with checking if the browser is iPad browser however this code fails sometimes when the string "ipad" is not there, when I tested on such browser sometimes the keyword is applewebkit, but who knows there could be more. So is there a
- GWT library for this?
- or a Javascript library for this?