# Android mobile device detection is too strict

**URL:** https://meta.discourse.org/t/android-mobile-device-detection-is-too-strict/40943
**Category:** Bug
**Created:** [3월 12, 2016, 5:41오후 UTC](https://meta.discourse.org/t/android-mobile-device-detection-is-too-strict/40943 "2016-03-12T17:41:03Z")
**Posts on this page:** 1
**Showing post:** 22

<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: [3월 15, 2016, 11: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.

---

_[View the full topic](https://meta.discourse.org/t/android-mobile-device-detection-is-too-strict/40943)._
