title: How to open a url in the native app instead of a browser?
body: <p>I found a question <a href="https://stackoverflow.com/questions/3922606/detect-an-application-is-installed-or-not">here</a>, but it will check a package name. What I want is to check a url (e.g. <a href="https://www.facebook.com" rel="nofollow noreferrer">https://www.facebook.com</a> or <a href="https://www.twitter.com" rel="nofollow noreferrer">https://www.twitter.com</a>) and open in in their native app if it's installed, or open it in the browser if it's not installed.</p>
  
  <pre><code>String url = "https://www.facebook.com";
  
  if (hasNativeApp()) {
      // open in native app
  } else {
      Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
      startActivity(intent);
  }
  </code></pre>