@Nullable
  public PackageManager getPackageManager() {
    if (packageManager != null) {
      return packageManager;
    }

    try {
      Class<?> pmClass = Class.forName("android.content.pm.PackageManager");
      final Method method = contextClass.getMethod("getPackageManager");
      final Object pm = method.invoke(getContextInstance());
      packageManager = new PackageManager(pmClass, pm);
    } catch (InvocationTargetException
        | IllegalAccessException
        | ClassNotFoundException
        | NoSuchMethodException e) {
      // Not Android
      e.printStackTrace();
    }
    return packageManager;
  }
Similar to <a
href="https://developer.android.com/reference/android/content/Context#getPackageManager()">Context#getPackageManager</a>
but performed through reflection.

@return the {@link PackageManager}
src/main/java/com/google/maps/android/Context.java