How to detect the stock Android browser

前端 未结 14 1898
不思量自难忘°
不思量自难忘° 2020-12-08 01:52

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_         


        
14条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-08 02:33

    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)

提交回复
热议问题