2

I am planning to use Wurfl in a web application in order to distinguish between mobile device and desktop browser. The isMobileBrowser(String userAgent) from net.sourceforge.wurfl.core.utils seems the appropriate function to do that.

Nevertheless looking at the source code of the 1.0.1-rc3 I can see that if the user agent string does not contain the "Tablet" word, it always returns false. I was reading this article http://wurfl.sourceforge.net/newapi/ and I would like to use the fuzzy match that is described there to identify the devices. Could be possible that am I using the wrong function?, if that is the case could you please point me to the right direction?.

Also , do you know where can I find the source code for the 1.0.1-rc4?.

ThinkingStiff
  • 64,767
  • 30
  • 146
  • 239
yeforriak
  • 1,705
  • 2
  • 18
  • 26

4 Answers4

4

You have to use those capabilities:

if(is_wireless_device=false and device_claims_web_support=true) {
the request is from web browser
}

via

fravelgue
  • 2,633
  • 2
  • 24
  • 23
  • If I use the code you propose I will need something like this: getDeviceForRequest(WURFLRequest request); to get the Device object, and then get and check these two capabilities. I was trying to find a high level method in the wurfl api. The function isMobileBrowser(String userAgent) from net.sourceforge.wurfl.core.utils seems the appropriate but having checked the source code, I found it does not do what I expected. – yeforriak Apr 13 '10 at 15:24
  • Sry, i have changed my answer. Yes you have to use those capabilities. – fravelgue Apr 13 '10 at 15:25
  • Any idea why the method isMobileBrowser(String userAgent) is there?. Here you can find the javadoc: http://wurfl.sourceforge.net/njava/javadocs/net/sourceforge/wurfl/core/utils/UserAgentUtils.html#isMobileBrowser(java.lang.String) . I am a bit confused about this method. – yeforriak Apr 13 '10 at 15:34
  • Sry, but i don´t know why, so it is a internal method. Googling i found msie uses Table for Tablet PC: http://www.zytrax.com/tech/web/msie-history.html – fravelgue Apr 13 '10 at 19:59
  • I asked the same question in the wml programming group and I found all the answers I needed :). http://tech.groups.yahoo.com/group/wmlprogramming/message/32344 – yeforriak Apr 14 '10 at 11:54
2

if($device->getCapability('is_wireless_device') == 'true') { //This is a mobile device } else { // this is for a browser }

This is what I am using to do my mobile device vs browser detection... Works seamlessly at the moment.

Derik Nel
  • 423
  • 2
  • 10
0

We tweaked the wurfl.xml file for detecting desktop.

<device id="generic_web_browser" user_agent="DO_NOT_MATCH_GENERIC_WEB_BROWSER" fall_back="generic">
    <group id="product_info">
      <capability name="has_qwerty_keyboard" value="true"/>
      <capability name="pointing_method" value="mouse"/>
       <capability name="device_os" value="**Desktop**"/> <!--Added desktop OS-->
      <capability name="model_name" value=""/>
      <capability name="can_skip_aligned_link_row" value="true"/>
      <capability name="device_claims_web_support" value="true"/>
      <capability name="is_wireless_device" value="false"/>
      <capability name="brand_name" value="generic web browser"/>
      <capability name="can_assign_phone_number" value="false"/>
      <capability name="release_date" value="1994_january"/>
    </group>

We are using WURFL with Liferay plugin and this is working fine for me

0

As of the current Wurfl release there is a "is_tablet" parameter. Wurfl Help Doc

actkatiemacias
  • 1,433
  • 2
  • 14
  • 16