The obvious way to detect Android by server is to search for "Android" string from User-Agent HTTP header. But - I've had complaints that this does not work on some devices (e.g. in my HTC Evo), they are not detected as Android. whatsmyuseragent.com gives for my HTC Evo 3D web browser: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/534.24 (KHTML, like Gecko) Chrome/11.0.696.34 Safari/534.24 . No Android string or version. It could be a security software on the device who alters it it, or HTC-specific issue, not sure about it.
Obviously Android Chrome on same device has another, and better UA: Mozilla/5.0 (Linux; Android 4.0.3; HTC EVO 3D X515m Build/IML74K) AppleWebKit/535.19 (KHTML, like Gecko) Chrome/18.0.1025.166 Mobile Safari/535.19 , but I cannot just hope that e.g. QR Code reader app opens Chrome and not the built-in Android browser, which has invalid UA.
Is there a good trick (javascript call?) to detect reliably Android across devices and browsers?
Edit: looks like same issue with Galaxy S III, same User-Agent string: Android Phone Browser Detection