code: public static boolean packageInstalled(@NotNull final Context context, @NotNull final String packageName) {
          final PackageManager packageManager = context.getPackageManager();
          boolean result = false;
          try {
              packageManager.getPackageInfo(packageName, PackageManager.GET_ACTIVITIES);
              result = true;
          } catch (PackageManager.NameNotFoundException ignore) {
          }
          Logger.d("packageInstalled() is ", result, " for ", packageName);
          return result;
      }
docs: Checks if an application is installed.
  
  @return true if the current thread it the UI thread.