title: Why does intent.resolveActivity(getPackageManager()) return null even though there is Activity to handle it?
body: <p>I'm following the <a href="https://codelabs.developers.google.com/android-training/" rel="nofollow noreferrer">Android Codelabs</a>, specifically I'm working on <a href="https://codelabs.developers.google.com/codelabs/android-training-activity-with-implicit-intent/index.html?index=..%2F..android-training#3" rel="nofollow noreferrer">this</a> Codelab with implicit intents.</p>
  <p>The Codelab has the following method:</p>
  <pre><code>public void openWebsite(View view) {
     String url = mWebsiteEditText.getText().toString();
  
     Uri webpage = Uri.parse(url);
     Intent intent = new Intent(Intent.ACTION_VIEW, webpage);
  
     if (intent.resolveActivity(getPackageManager()) != null) {
         startActivity(intent);
     } else {
         Log.d(&quot;ImplicitIntents&quot;, &quot;Can't handle this intent!&quot;);
     }
  }
  </code></pre>
  <p>The problem is that the <code>intent.resolveActivity(getPackageManager())</code> returns null, but if I omit this and just call the <code>startActivity(intent)</code>, it works fine and opens the Uri in Google Chrome.</p>
  <p>I'm wondering why <code>intent.resolveActivity(getPackageManager())</code> returns null, even thought the Uri can be opened in Google Chrome?</p>
  <p>The <strong>Manifest</strong> file:</p>
  <pre><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;manifest xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
      package=&quot;com.example.implicitintents&quot;&gt;
  
      &lt;application
          android:allowBackup=&quot;true&quot;
          android:icon=&quot;@mipmap/ic_launcher&quot;
          android:label=&quot;@string/app_name&quot;
          android:roundIcon=&quot;@mipmap/ic_launcher_round&quot;
          android:supportsRtl=&quot;true&quot;
          android:theme=&quot;@style/AppTheme&quot;&gt;
          &lt;activity android:name=&quot;.MainActivity&quot;&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name=&quot;android.intent.action.MAIN&quot; /&gt;
  
                  &lt;category android:name=&quot;android.intent.category.LAUNCHER&quot; /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  <p>In this case the URL that we want to open comes from <code>EditText</code> field, so we can't use an <code>intent-filter</code> with <code>android:host</code> as described <a href="https://stackoverflow.com/a/47647713/7248094">here</a>.</p>