Skip to content

Instantly share code, notes, and snippets.

@takeshi81
Last active April 19, 2016 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save takeshi81/1bb5e2cbff72a5ef46cdcc51dc9857ac to your computer and use it in GitHub Desktop.
Save takeshi81/1bb5e2cbff72a5ef46cdcc51dc9857ac to your computer and use it in GitHub Desktop.
Fast detection for Android. ( using String.prototype.indexOf, not RegExp )
var ua = navigator.userAgent.toLowerCase();
var isLollipop = ua.indexOf("android 5") > -1; // If Android 5.x is true
var isAndroid4x = ua.indexOf("android 4") > -1; // If Android 4.x is true
var isAndroid2x = ua.indexOf("android 2") > -1; // If Android 2.x is true
var isOldAndroid = isLollipop || isAndroid4x || isAndroid2x; // Return true if Android version is 5.x or older
if (isOldAndroid) {
// Write here.
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment