# Android mobile device detection is too strict

**URL:** https://meta.discourse.org/t/android-mobile-device-detection-is-too-strict/40943
**Category:** Bug
**Created:** [12 maart 2016 om 17:41 UTC](https://meta.discourse.org/t/android-mobile-device-detection-is-too-strict/40943 "2016-03-12T17:41:03Z")
**Posts on this page:** 4
**Page:** 2

<div class="post-metadata">

### Author: ![evantill](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/evantill/32/116219_2.png) [@evantill](https://meta.discourse.org/u/evantill)
#### Post date: [15 maart 2016 om 08:02 UTC](https://meta.discourse.org/t/android-mobile-device-detection-is-too-strict/40943/21 "2016-03-15T08:02:17Z")

</div>

Thank you @sam. Seems to solve my problem 🙏

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [15 maart 2016 om 23:53 UTC](https://meta.discourse.org/t/android-mobile-device-detection-is-too-strict/40943/22 "2016-03-15T23:53:23Z")

</div>

All right here’s what we have ~~had~~

```ruby
user_agent =~ /Mobile|webOS|Nexus (5|6|7)/ && !(user_agent =~ /iPad/)

```

Here is what I am changing it to:

```ruby
user_agent =~ /Mobile|Android|webOS/ && !(user_agent =~ /iPad|Nexus (9|10)/)

```

My iPhone 6s — matches `Mobile`

`Mozilla/5.0 (iPhone; CPU iPhone OS 9_2_1 like Mac OS X) AppleWebKit/601.1.46 (KHTML, like Gecko) Version/9.0 Mobile/13D15 Safari/601.1`

My Nexus 7 — matches `Android`

`Mozilla/5.0 (Linux; Android 6.0.1; Nexus 7 Build/MMB29Q) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Safari/537.36`

Nexus 10 — not-matches `Nexus 10`

`Mozilla/5.0 (Linux; Android 5.1.1; Nexus 10 Build/LMY49G) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Safari/537.36`

(this same regex is duplicated in two places, @sam said he’d clean it up)

Anyway, this **broadens the matching substantially for Android**. I am very fine with prioritizing phone and phablet layout for Android, as [tablets are really a non-starter in the Android space](https://twitter.com/BenedictEvans/status/708016471759171584). We feel it is the far lesser evil to have the (rare) Android full size tablet detected as mobile by mistake, than have one of the trillions of random Android phone models out there be detected as desktop by mistake.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [16 maart 2016 om 00:56 UTC](https://meta.discourse.org/t/android-mobile-device-detection-is-too-strict/40943/23 "2016-03-16T00:56:37Z")

</div>

GALAXY S7 CHROME

A Analyze  
Mozilla/5.0 (Linux; Android 6.0.1; SM-G930V Build/MMB29M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.91 Mobile Safari/537.36

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [18 maart 2016 om 00:20 UTC](https://meta.discourse.org/t/android-mobile-device-detection-is-too-strict/40943/24 "2016-03-18T00:20:14Z")

</div>

This topic was automatically closed after 2 days. New replies are no longer allowed.

[Vorige pagina](https://meta.discourse.org/t/android-mobile-device-detection-is-too-strict/40943.md?page=1)
