जवाबों:
उस पर एक नज़र: http://davidwalsh.name/detect-android
जावास्क्रिप्ट:
var ua = navigator.userAgent.toLowerCase();
var isAndroid = ua.indexOf("android") > -1; //&& ua.indexOf("mobile");
if(isAndroid) {
// Do something!
// Redirect to Android-site?
window.location = 'http://android.davidwalsh.name';
}
पीएचपी:
$ua = strtolower($_SERVER['HTTP_USER_AGENT']);
if(stripos($ua,'android') !== false) { // && stripos($ua,'mobile') !== false) {
header('Location: http://android.davidwalsh.name');
exit();
}
संपादित करें : जैसा कि कुछ टिप्पणियों में बताया गया है, यह 99% मामलों में काम करेगा, लेकिन कुछ किनारे मामलों को कवर नहीं किया गया है। यदि आपको JS में अधिक उन्नत और बुलेटप्रूफ समाधान की आवश्यकता है, तो आपको platform.js का उपयोग करना चाहिए: https://github.com/bestiejs/platform.js
var isAndroid = /Android/i.test(navigator.userAgent)
Mozilla/5.0 (Mobile; Windows Phone 8.1; Android 4.0; ARM; Trident/7.0; Touch; rv:11.0; IEMobile/11.0; NOKIA; Lumia 625; Orange) like iPhone OS 7_0_3 Mac OS X AppleWebKit/537 (KHTML, like Gecko) Mobile Safari/537
कैसे इस एक लाइनर के बारे में?
var isAndroid = /(android)/i.test(navigator.userAgent);
iसंशोधक केस-संवेदी मिलान प्रदर्शन करने के लिए प्रयोग किया जाता है।
कॉर्डोवा AdMob परीक्षण परियोजना से ली गई तकनीक: https://github.com/floatinghotpot/cordova-admob-pro/wiki/00.-How-To-Use-with-PhoneGap-Bild
मुझे लगता है कि मिशल का जवाब सबसे अच्छा है, लेकिन हम इसे एक कदम आगे ले जा सकते हैं और मूल प्रश्न के अनुसार एंड्रॉइड सीएसएस को गतिशील रूप से लोड कर सकते हैं:
var isAndroid = /(android)/i.test(navigator.userAgent);
if (isAndroid) {
var css = document.createElement("link");
css.setAttribute("rel", "stylesheet");
css.setAttribute("type", "text/css");
css.setAttribute("href", "/css/android.css");
document.body.appendChild(css);
}
;(function() {
var redirect = false
if (navigator.userAgent.match(/iPhone/i)) {
redirect = true
}
if (navigator.userAgent.match(/iPod/i)) {
redirect = true
}
var isAndroid = /(android)/i.test(navigator.userAgent)
var isMobile = /(mobile)/i.test(navigator.userAgent)
if (isAndroid && isMobile) {
redirect = true
}
if (redirect) {
window.location.replace('jQueryMobileSite')
}
})()
js संस्करण, iPad भी पकड़ता है:
var is_mobile = /mobile|android/i.test (navigator.userAgent);