code: @Nullable
      public static PackageInfo getPackageInfo(@NonNull Context context, @NonNull String packageName) {
          try {
              return context.getPackageManager().getPackageInfo(packageName, PackageManager.GET_META_DATA);
          } catch (PackageManager.NameNotFoundException e) {
              return null;
          }
      }
docs: A safe method to obtain {@link PackageInfo} from {@link android.content.pm.PackageManager}
  If package is not available, it would just return null.
  
  @param context to be used for looking
  @param packageName to look up against context
  @return {@link PackageInfo} retrieved from Context.