title: App crashing with 'boolean android.content.Intent.migrateExtraStreamToClipData()' on a null object reference' even when try/catch block is there
body: <p>I'm trying to open certain apps using there package names and for that I'm using this code:</p>
  
  <pre><code>public void openAppHavingPackageName(String packageName, String appName) {
          try {
              Intent intent = getBaseContext().getPackageManager().getLaunchIntentForPackage(packageName);
              startActivity(intent);
          } catch (ActivityNotFoundException e) {
              Log.e(TAG, e.getMessage());
          }
  }
  </code></pre>
  
  <p>It is working fine when I'm trying to open the apps which are installed in my phone but when I tried to open an app which is not in my phone, the app crashed giving this error:</p>
  
  <p><code>java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.content.Intent.migrateExtraStreamToClipData()' on a null object reference</code> </p>
  
  <p>on the line </p>
  
  <p><code>startActivity(intent);</code></p>
  
  <p>As you can see I have a <code>try/catch</code> block there then why the exception is not getting caught up and instead the code is getting run causing the crash?</p>