2

I've found plenty of answers on this. The one I'm trying now is:

 /(android)/i.test(navigator.userAgent)

But in Chrome on Windows I get true. I'm trying to detect when my user is on an Android device (to point them to the Play Store listing). Is there any reliable way to achieve this?

BLAZORLOVER
  • 1,678
  • 2
  • 15
  • 24

1 Answers1

2

I just tried this answer, and the code worked for me: Detect Android phone via Javascript / jQuery

Here is their code:

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';
}

I also made a CodePen here where you can test it out.

I tested my CodePen on Chrome for Windows, Chrome for Mac, and Chrome for Android, and it worked correctly for all.

Community
  • 1
  • 1
Joseph Beard
  • 181
  • 3
  • 13