don’t know where to post this… why is there no JAVA forum (there is PHP, python, etc… why not JAVA???)
is there a java class for device-detection like this PHP class?
using the tradicional CSS media queries, I find that some phones are so large that in landscape they load the CSS for tablets, and some tablets are so small that when you display them portrait they load the CSS for phones…
this PHP class for detecting device is much more reliable than the CSS media queries (& and I have tested it extensively on a website I did in PHP and so far it has never failed…) I would like to know if there is a class like this in java…
(theoretically this class could be re-written in java, I suppose, but I don’t know if I could do that…
although I would enjoy the challenge, it would take me far too long…)
lines like
return self::$phoneDevices;
would stump me…
(this is not the same as
return $phoneDevices;
I assume??
(and, just out of curiosity: would re-writing this class in java violate the license of this PHP class Mobile_Detect?)
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
I have asked this many times. I gave up. lol The JVM is quite large and encompasses more than a few languages.
I dl’d and compiled the class you linked to… (UAgentInfo.java) will play w/it a bit…
(essentially I need to distinguish betw computer, tablet, & phone… will see what I can do w/this class…)
(have limited access to internet now, can’t do extensive searching…)
The class should be in your src folder, not WEB-INF and compile it with your project. Just make sure you change the package name to wherever you put it.
So if you want to keep that package name you put it:
/src/com/handinteractive/mobile/UAgentInfo
Then <%@ page import="com.handinteractive.mobile.*" %> should work.
Generally it’s considered bad practice to use scriplets in the page like what you’re trying to do. It should all be done by the Servlet and parsed by the template engine like JSTL or Thymeleaf.
the class should be in my src folder??? say what? the compiled class?
hmmm…
(I don’t compile my project… it’s just JSP’s, personal site, fairly small… Tomcat compiles them for me…
I compiled this class myself “by hand” on the shell, the old-fashioned way (using javac…