Javascript : Identify whether it is a desktop Linux or Android -


unable identify whether linux desktop machine or android device using navigator.useragent or navigator.platform android device's have string linux in both. details follows

device                           os               navigator.platform   -------------------------------------------------------------------- samsung galaxy s3                android 4.3      linux armv7l htc 1                          android 4.4.2    linux armv7l sony xperia z                    android 4.2.2    linux armv7l motorola moto g                  android 4.4.2    linux armv7l samsung galaxy tab 3             android 4.2.2    linux i686 nexus 10                         android 4.4.2    linux armv7l lenovo yoga                      android 4.2.2    linux armv7l 

navigator.useragent

mozilla/5.0 (linux; u; android 2.2; en-us; sch-i800 build/froyo) applewebkit/533.1 (khtml, gecko) version/4.0 mobile safari/533.1 

even tried touch events, linux desktop can have touch or can emulate touch. please help

update: solution should detect linux if desktop browser's emulate device active. view details

you can try this:

if (navigator.useragent.match(/android/i)) {    // it's andorid } else if (navigator.useragent.match(/linux/i)) {    // it's linux } 

Popular posts from this blog

c# - ODP.NET Oracle.ManagedDataAccess causes ORA-12537 network session end of file -

matlab - Compression and Decompression of ECG Signal using HUFFMAN ALGORITHM -

utf 8 - split utf-8 string into bytes in python -