Navigating to http://whatsmyuseragent.com/ shows me my stock Android browser on my Galaxy Nexus running 4.2.1 has the user agent
Mozilla/5.0 (X11; Linux x86_
You must remove SamsungBrowser from your regexp.
For SamSungBrowser, you can use SamsungBrowser/([0-9]*.[0-9]*) or Android.*SAMSUNG.*Version/([0-9]*.[0-9]*) for old browser
http://developer.samsung.com/technical-doc/view.do?v=T000000203
I think you are searching for this:
Android native browser not updated above version 534.30 so you can filter to the version and Android UA string combination (above we can presume its a Chrome browser)
Here's my sample JavaScript code:
(If you need specific styling I would add a class to the body with the following JS snippet)
var defectAndroid = $window.navigator && $window.navigator.userAgent.indexOf('534.30') > 0 && $window.navigator.userAgent.toLowerCase().match(/android/);
if (defectAndroid) {
// sample code specific for your Android Stock browser
}
(Some Android devices reporting 'android' that's why we need the lower case conversation)
efusien's answer (Nov 11 '13 at 20:18) works for me, although a variable hasn't been declared, and a comma was used in one spot instead of a semicolon, which results in a big fail for anyone looking for a copy/paste answer.
The following is what worked for me, including a practical example using an "if it's the native browser" condition:
var navU = navigator.userAgent;
// Android Mobile
var isAndroidMobile = navU.indexOf('Android') > -1 && navU.indexOf('Mozilla/5.0') > -1 && navU.indexOf('AppleWebKit') > -1;
// Android Browser (not Chrome)
var regExAppleWebKit = new RegExp(/AppleWebKit\/([\d.]+)/);
var resultAppleWebKitRegEx = regExAppleWebKit.exec(navU);
var appleWebKitVersion = (resultAppleWebKitRegEx === null ? null : parseFloat(regExAppleWebKit.exec(navU)[1]));
var isAndroidBrowser = isAndroidMobile && appleWebKitVersion !== null && appleWebKitVersion < 537;
$(window).load(function() {
if (isAndroidBrowser) {
// It's Android's native browser (and not Chrome), so do something
}
});
If JavaScript instead of server-side UA sniffing is an option for you, try (!!window.chrome) && (!window.chrome.app).
I can't guarantee, however, that this one is "safe", will work "forever", or something like that. Consider it an evil hack to be used for testing purposes only.
Explanation: Chrome (or Chromium?) Browsers (well, the ones I tested here, which were Chrome and Android stock on Cyanogenmod 10) have an object named window.chrome, but on the Android stock browser, the one I tested at least, this object does not have the app property.
Edit: Seems like older Chrome versions will give false positives with this solution. In turn, newer versions of the stock browser will most likely give "false negatives".
Your'e not getting android in the UA because you're using Desktop View. There's seemingly no way to identify that this is a mobile device in that mode. Once you'll switch to normal view you'll see the right UA.
var navU = navigator.userAgent;
// Android Mobile
var isAndroidMobile = navU.indexOf('Android') > -1 && navU.indexOf('Mozilla/5.0') > -1 && navU.indexOf('AppleWebKit') > -1;
// Apple webkit
var regExAppleWebKit = new RegExp(/AppleWebKit\/([\d.]+)/);
var resultAppleWebKitRegEx = regExAppleWebKit.exec(navU);
var appleWebKitVersion = (resultAppleWebKitRegEx === null ? null : parseFloat(regExAppleWebKit.exec(navU)[1]));
// Chrome
var regExChrome = new RegExp(/Chrome\/([\d.]+)/);
var resultChromeRegEx = regExChrome.exec(navU);
var chromeVersion = (resultChromeRegEx === null ? null : parseFloat(regExChrome.exec(navU)[1]));
// Native Android Browser
var isAndroidBrowser = isAndroidMobile && (appleWebKitVersion !== null && appleWebKitVersion < 537) || (chromeVersion !== null && chromeVersion < 37);