title: "No Activity found to handle Intent" error occurs when its going to load a URL in browser
body: <p>I've checked similar questions about <code>No Activity found to handle Intent</code> error. none of them covered my problem.</p>
  
  <p>I'm getting this error in my Sentry logs when the app is going to open a URL in Chrome browser using Intent in an <strong>AppCompatActivity</strong>:</p>
  
  <pre><code>android.content.ActivityNotFoundException: No Activity found to handle Intent
  { act=android.intent.action.VIEW dat=https://www.example.com/...
  flg=0x10000000 pkg=com.android.chrome }
  </code></pre>
  
  <p>This is my code:</p>
  
  <pre><code>Intent intent = new Intent(Intent.ACTION_VIEW);
  intent.setData(Uri.parse(url));
  intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  intent.setPackage("com.android.chrome");
  
  if (MyMethods.isAppInstalled(getApplicationContext(), "com.android.chrome")) {
      try {
          startActivity(intent);
      } catch (ActivityNotFoundException ex) {
          SentryLog.warn(ex);
          // Chrome browser presumably not installed so allow user to choose instead
          intent.setPackage(null);
          startActivity(intent);
      }
  } else {
      // Chrome browser presumably not installed so allow user to choose instead
      intent.setPackage(null);
      startActivity(intent);
  }
  </code></pre>
  
  <p><code>SentryLog.warn(ex);</code> had reported the error.</p>
  
  <p>and this is <code>isAppInstalled()</code> method which is in MyMethods class:</p>
  
  <pre><code>public static boolean isAppInstalled(Context context, String packageName) {
      try {
          if (context != null) {
              context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
          }
          return true;
      } catch (PackageManager.NameNotFoundException e) {
          MyLog.w(TAG, new Throwable().getStackTrace()[0].getLineNumber(), e);
          e.printStackTrace();
      }
  
      return false;
  }
  </code></pre>
  
  <p>sometimes it goes to catch scope. As you see I checked if chrome is installed on device or not, so it's installed if it doesn't go to else! in this situation why it couldn't execute <code>startActivity(intent);</code> and it went to catch scope?</p>
  
  <p>‍
  My code is in an Activity, so should I use <code>intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);</code> or not?</p>