title: Check if intent uri is available
body: <p>I have an app that sometimes links to imdb. I can do this with <code>http://m.imdb.com/find</code> or if it is available <code>imdb:///find</code>. My trouble is I can't find a way to check whether the <code>imdb://</code> is available before it is too late.</p>
  
  <p>Because the link is clicked on by the user, I can't catch the <code>android.content.ActivityNotFoundException</code> exception.</p>
  
  <p>Am I missing something obvious?</p>
  
  <hr>
  
  <p><strong>Solution:</strong></p>
  
  <p>By inazaruk's suggestion I'm now using the follwing code:</p>
  
  <pre><code>public static boolean isUriAvailable(Context context, String uri) {
      Intent test = new Intent(Intent.ACTION_VIEW, Uri.parse(uri));
      return context.getPackageManager().resolveActivity(test, 0) != null;
  }
  </code></pre>
  
  <p>The method must be called with a direct uri to what you are requesting, like <code>imdb:///find</code> rather than just <code>imdb://</code>.</p>