Page: 1, 2  Next

Android 4+ tablet
timgolding
Status: Interested
Joined: 30 Nov 2011
Posts: 26
Reply Quote
I have been using the php broswer detection script to test various android tablets. while android 3 and below gets detected as a tablet. Anything from andoid 4 or above get treated as a mobile. Here are the UA strings that fail.
:: Quote ::


Mozilla/5.0 (Linux; U; Android 4.0.3; en-us; sdk Build/MR1) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Safari/534.30

Mozilla/5.0 (Linux; U; Android 4.3; en-us; sdk Build/MR1) AppleWebKit/536.23 (KHTML, like Gecko) Version/4.3 Mobile Safari/536.23

Mozilla/5.0 (Linux; U; Android 4.3; en-us; sdk Build/MR1) AppleWebKit/536.23 (KHTML, like Gecko) Version/4.3 Mobile Safari/536.23

Mozilla/5.0 (Linux; Android 4.4; Nexus 5 Build/BuildID) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/30.0.0.0 Mobile Safari/537.36

Mozilla/5.0 (Linux; U; Android 4.2; en-us; sdk Build/MR1) AppleWebKit/535.19 (KHTML, like Gecko) Version/4.2 Safari/535.19


Mozilla/5.0 (Linux; U; Android 4.1; en-us; sdk Build/MR1) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.1 Safari/534.30



Will there be a fix for android 4 tablet browsers or should or how can i edit the code?

These UA are generated from a testing tool we use called browseemall, but i noticed the UA string for mobile andoid was the same as the ua string for tablet. Is this a problem with the UA strings of android or the software i am using?
Back to top
timgolding
Status: Interested
Joined: 30 Nov 2011
Posts: 26
Reply Quote
Actually after some hunting about i found this article.

https://developers.google.com/chrome/mobile/docs/user-agent

which shows a regex used to determine if it is on tablet or mobile.

:: Quote ::

If you are parsing user agent strings using regular expressions, the following can be used to check against Chrome for Android phones and Android tablets:

Phone pattern: 'Android' + 'Chrome/[.0-9]* Mobile'
Tablet pattern: 'Android' + 'Chrome/[.0-9]* (?!Mobile)'


If this doc posted by google is correct this suggest that the word mobile should not be in any of these ua strings generated by browseemall for android tablet tests.
Back to top
timgolding
Status: Interested
Joined: 30 Nov 2011
Posts: 26
Reply Quote
Actually this is for article is for chrome. But here is some information about the stock browser

developer.android.com/guide/webapps/best-practices.html

It just says look for the word mobile if its not present then its a tablet.
Back to top
timgolding
Status: Interested
Joined: 30 Nov 2011
Posts: 26
Reply Quote
Here is my fix


Line 1282
:: Code ::




$k_count = count( $a_mobile_tablet );
   for ( $k = 0; $k < $k_count; $k++ ) {
      if ( strstr( $pv_browser_user_agent, $a_mobile_tablet[$k] ) ) {
         $mobile_tablet = trim( $a_mobile_tablet[$k] );
         if ( $mobile_tablet == 'gt-p' || $mobile_tablet == 'sch-i' ) {
            $mobile_tablet = 'galaxy-' . $mobile_tablet;
         }
         break;
      }   // android 4 hack
      elseif(stristr($pv_browser_user_agent, 'android 4' ) && !stristr($pv_browser_user_agent, 'mobile'))
      {
         $mobile_tablet = 'android 4';
      }


Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3753
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
that's been updated now, 5.5.3, thanks for the heads up on this.

I don't expect this to be a lasting fix, particularly not now that Chrome OS is being actually delivered and used by people.

But for now, as with the last android 3 hack, this is good enough.

Note that only android 3 devices showed as tablets, not earlier.

Your sample UA strings confused me initially since I thought they were examples of valid tablet ua, but only the ones without 'mobile' are, of course.

I also updated the techpatterns.com/forums/about304.html useragent string switcher list for testing this.
Back to top
timgolding
Status: Interested
Joined: 30 Nov 2011
Posts: 26
Reply Quote
Thanks for the fix.

I will use 5.5.3 from now on

I contacted the developers of Browseemall and I pointed out that they shouldn't have the term mobile in the UA strings for a tablet. So they are doing a bug fix now.

I forgot to break out of the loop in that code.

:: Code ::

$mobile_tablet = 'android 4';
break;

Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3753
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
I'm not using this test in the loop, I test first before the loop runs, that way the test doesn't have to run each time.

There will be a fair number of android devices out there I think, more and more, so might as well just get it handled.

I'm also testing for android versions > 4 at the same time, though 10 to 1 this will change in the future.

Just as an aside, the browser detection script is designed so that a newer version can always be dropped in without any recoding of your logic, ie, it has stable output, the only changes are added to the arrays at the end. In other words, as long as you never use count of array to do anything in your programming, the browser detector should always work in all future releases as long as it worked today.
Back to top
timgolding
Status: Interested
Joined: 30 Nov 2011
Posts: 26
Reply Quote
Cool thanks,

I saw 5.5.3 and downloaded it. Thanks for helping me with this issue.
Back to top
techAdmin
Status: Site Admin
Joined: 26 Sep 2003
Posts: 3753
Location: East Coast, West Coast? I know it's one of them.
Reply Quote
Specific end user cases and weird UA behavior handlings etc are what keep this script relevant.

When I added mobile stuff, then tablet, I knew that would involve a lot of changes over time because there is simply no convention about how those should work, what is a tablet, what is a phone, etc, or the new 'phablets' as they are called (midsized devices), and chrome OS which I should look up a bit since it's also out in the market now as a real system on laptops.

I believe though I'm not certain that the script will identify chrome os devices as tablets now as well.
Back to top
timgolding
Status: Interested
Joined: 30 Nov 2011
Posts: 26
Reply Quote
its a ongoing problem I can see how much time this must take. I suppose time will tell if you can identify chrome os devices as tablets. i will let you know if i ever get to test on devices with crome at the moment the android tests on my testing tool are on the stock browser but i have a mobile to test chrome. Maybe i will install it and give it a try. I will let you know the results. So many browsers so many results. This Ua string is nightmare. I wonder is the JS script a more sound way of doing these tests? That means relying on the user having JS enabled. For that reason i have always prefered the php script
Back to top
Display posts from previous:   
Page: 1, 2  Next
All times are GMT - 8 Hours