title: How to Detect Device Type without Spring-Mobile
body: <p>I know there are multiple questions asked like that but I have tried all of their solutions and none of them worked for me.
  Before now, we were using <code>Spring-Mobile</code> for detection of Device that is requesting from the browser. But because its support is no longer available, we need to switch to a different strategy.</p>
  <p>I have seen different solutions using <code>HttpServletRequest</code> to detect the device type (if it is a mobile, Tablet or Desktop) from its <code>Header</code> through <code>User-Agent</code>. Following is the code I have used to detect Mobile device using this approach:</p>
  <pre><code>String userAgent = request.getHeader(&quot;User-Agent&quot;);
  System.out.println(&quot;User-Agent =&gt; &quot; + userAgent.contains(&quot;Mobi&quot;)); //prints false
  </code></pre>
  <p>I have tried this by sending request from browser through inspect element and also by using original Mobile Device but in both cases, it return <code>false</code>.</p>
  <h1>Mobileesp.org:</h1>
  <p>I also saw a solution that used <a href="https://github.com/ahand/mobileesp" rel="nofollow noreferrer">mobileesp.org</a> but I am not quite sure If I am implementing it correctly in my application or not. I only copied its folder of <code>Java</code> and pasted in my application. There, I called its constructor and tried to detect mobile devices but all the methods returned <code>false</code> on mobile detection. Again, I tested that on real device and on browser as well. Following is my code:</p>
  <pre><code>        String userAgent = request.getHeader(&quot;User-Agent&quot;); // request =&gt; HttpServletRequest (javax.servlet.http.HttpServletRequest)
          UAgentInfo user = new UAgentInfo(userAgent, &quot;&quot;);
  
          // All of Below methods are returning False
          System.out.println(user.detectAndroidPhone());
          System.out.println(user.isAndroidPhone);
          System.out.println(user.isIphone);
          System.out.println(user.isMobilePhone);
          System.out.println(user.detectAndroid());
          System.out.println(user.detectSmartphone());
          System.out.println(user.detectAndroidTablet());
          System.out.println(user.detectMobileQuick());
          System.out.println(user.detectMobileLong());
          System.out.println(user.isAndroid);
  </code></pre>
  <p>Your help is really appreciated. Thanks!</p>