code: static boolean isPackageInstalled(Context context) {
          boolean isInstalled = false;
          if (context != null) {
              try {
                  final PackageManager packageManager = context.getPackageManager();
                  Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
                  if (intent == null) {
                      return false;
                  }
                  List<ResolveInfo> list = packageManager.queryIntentActivities(intent, PackageManager.MATCH_DEFAULT_ONLY);
  
                  isInstalled = (list != null && list.size() > 0);
              } catch (Exception e) {
                  PrefHelper.LogException("Error obtaining PackageInfo", e);
              }
          }
  
          return isInstalled;
      }
docs: Determine if the package is installed.
  @param context Context
  @return true if the package is installed.