code: @Nullable
      private String getPackageName(@NonNull ComponentName resolveActivity, @NonNull List<Intent> initialIntents) {
          String packageName = resolveActivity.getPackageName();
          if (packageName.equals("android")) {
              //multiple activities support the intent and no default is set
              if (initialIntents.size() > 1) {
                  packageName = null;
              } else if (initialIntents.size() == 1) {
                  //only one of them supports attachments, use that one
                  packageName = initialIntents.get(0).getPackage();
              }
          }
          return packageName;
      }
docs: Finds the package name of the default email client supporting attachments
  
  @param resolveActivity the resolved activity
  @param initialIntents  a list of intents to be used when
  @return package name of the default email client, or null if more than one app match