1

What I want to do is that users open this page, this page will open the custom URL, if users have my app, then my app will be launched, or it will redirect to Google Play's website.

I found the code online. The code below has problems that type of variable state is not boolean. When I use my android phone to open this page, it will all execute no matter the codes in if or else.

Is thee anybody know how to fix it or it is impossible to do this?

if (navigator.userAgent.match(/android/i)){

    var state = null;
    try {
      state = window.open("custom URL", '_blank');
    } catch(e) {}
    if (state) {
      window.close();
    } else {
      window.location = "Google Play's Link";
    }
  }
Ansgar Wiechers
  • 175,025
  • 22
  • 204
  • 278
user2117945
  • 35
  • 1
  • 5
  • You have to add the intent on app for that .. see this - http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser – Neha Mar 17 '14 at 07:04
  • visit http://stackoverflow.com/questions/6888867/detect-from-browser-if-a-specific-application-is-installed-in-android – Jitesh Upadhyay Mar 17 '14 at 07:08
  • Yes, I did, if I use my custom URL, it can launch my APP. All I want to do is identify if the custom URL is available. If not, it means users do not have my APP, then direct them to google play to download it. Or they can just launch my APP. – user2117945 Mar 17 '14 at 07:13

0 Answers0