Read version code from the manifest of the context.
@param context the context.
@param fallback fallback value of the version code.
@return the version code, or fallback value if not found.
557789
public static int getVersionCode(Context context, int fallback) {
        try {
            PackageManager manager = context.getPackageManager();
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
            return info.versionCode;
        } catch (NameNotFoundException e) {
            Log.e(TAG, "no such package installed on the device: ", e);
        }
        return fallback;
    }
280352
static String getAppVersion(Context context) {
        String appVersion = "";
        if (context != null) {
            try {
                final PackageInfo packageInfo = context.getPackageManager().getPackageInfo(context.getPackageName(), 0);
                appVersion = packageInfo.versionName;
            } catch (Exception e) {
                PrefHelper.LogException("Error obtaining AppVersion", e);
            }
        }
        return (TextUtils.isEmpty(appVersion) ? BLANK : appVersion);
    }
92957
public static String getVersion(String groupId, String artifactId, String defaultVersion) {
        String answer = getVersion(groupId, artifactId);
        if (Strings.isNullOrBlank(answer)) {
            answer = defaultVersion;
        }
        return answer;
    }
175970
public Apptentive.DateTime getTimeAtInstallForVersionCode(int versionCode) {
		for (VersionHistoryItem item : versionHistoryItems) {
			if (item.getVersionCode() == versionCode) {
				return new Apptentive.DateTime(item.getTimestamp());
			}
		}
		return new Apptentive.DateTime(Util.currentTimeSeconds());
	}
533558
private static String getVersion(final Class<?> clazz) {
		CodeSource source = clazz.getProtectionDomain().getCodeSource();
		URL location = source.getLocation();

		try {
			Path path = Paths.get(location.toURI());
			return Files.isRegularFile(path) ? getVersionFromJar(path) : getVersionFromPom(path);
		} catch (URISyntaxException ex) {
			Logger.error(ex, "Unknown location: \"{}\"", location);
			return null;
		}
	}
476473
public com.google.appengine.v1.Version getVersion() {
    return version_ == null ? com.google.appengine.v1.Version.getDefaultInstance() : version_;
  }
71765
function loadCurrentVersion (options, context) {
  return new Extension(options, context).read()
    .then(function (response) {
      let version = response.sys.version;

      options.version = version;
      return options;
    });
}
265560
public static ManifestVersion of(final URL url)
	{
		final ManifestVersion version = new ManifestVersion();
		if (url != null)
		{
			URLConnection urlConnection = null;
			try
			{
				urlConnection = url.openConnection();
				version.setLastModified(LocalDateTime.ofInstant(
					Instant.ofEpochMilli(urlConnection.getLastModified()), ZoneId.systemDefault()));
				version.setManifest(new Manifest(urlConnection.getInputStream()));
				version
					.setTitle(version.getManifestAttribute(Attributes.Name.IMPLEMENTATION_TITLE));
				version.setVersion(
					version.getManifestAttribute(Attributes.Name.IMPLEMENTATION_VERSION));
			}
			catch (final IOException e)
			{
				throw new RuntimeException("Error while try to load manifest file from " + url, e);
			}
		}
		return version;
	}
231221
public String getVersion()
	{
		String str = null;

		if ((version >= 0) && (version < versionLabels.length))
		{
			str = versionLabels[version];
		}

		return str;
	}
251649
static Map<String, String> getVersionAttributes(URL url) throws IOException {
        Map<String, String> ret = new LinkedHashMap<>();
        try (InputStream inputStream = url.openStream()) {
            Manifest manifest = new Manifest(inputStream);
            Attributes attributes = manifest.getMainAttributes();
            for (String key : VERSION_ATTRIBUTES) {
                final String value = attributes.getValue(key);
                ret.put(key, value == null ? UNKNOWN_VALUE : value);
            }
        }
        return ret;
    }
1194884
public static String jarVersion(Class<?> jarClass) {
    String j2objcVersion = null;

    String path = jarClass.getProtectionDomain().getCodeSource().getLocation().getPath();
    try (JarFile jar = new JarFile(URLDecoder.decode(path, "UTF-8"))) {
      Manifest manifest = jar.getManifest();
      j2objcVersion = manifest.getMainAttributes().getValue("version");
    } catch (IOException e) {
      // fall-through
    }
    if (j2objcVersion == null) {
      j2objcVersion = "(j2objc version not available)";
    }

    String javacVersion = Parser.newParser(null).version();
    return String.format("%s (javac %s)", j2objcVersion, javacVersion);
  }
921980
@Nullable
    public static String getPackageInstaller(@NonNull final Context context) {
        final PackageManager packageManager = context.getPackageManager();
        return packageManager.getInstallerPackageName(context.getPackageName());
    }
978200
public static String getResourceVersion(HasMetadata entity) {
    if (entity != null) {
      ObjectMeta metadata = entity.getMetadata();
      if (metadata != null) {
        String resourceVersion = metadata.getResourceVersion();
        if (!Utils.isNullOrEmpty(resourceVersion)) {
          return resourceVersion;
        }
      }
    }
    return null;
  }
557293
public static String getVersion(InputStream is) {
		try {
			String text = readAsString(is);
			return getVersionFromText(text);
		} catch (IOException e) {
			LOG.error(e.getMessage(), e);
			return null;
		}
	}
509707
public static String getVersionName(Context context) {
        try {
            PackageManager manager = context.getPackageManager();
            PackageInfo info = manager.getPackageInfo(context.getPackageName(), 0);
            return info.versionName;
        } catch (NameNotFoundException e) {
            throw new IllegalStateException("no such package installed on the device: ", e);
        }
    }
280624
private static int getAppVersion(Context context) {
        try {
            PackageInfo packageInfo = context.getPackageManager()
                    .getPackageInfo(context.getPackageName(), 0);
            return packageInfo.versionCode;
        } catch (NameNotFoundException e) {
            // should never happen
            throw new RuntimeException("Coult not get package name: " + e);
        }
    }
376256
public static String getVersion() {

        String FATHOM_PROPERTIES = "fathom/version.properties";
        String version = null;

        URL url = ClassUtil.getResource(FATHOM_PROPERTIES);
        Preconditions.checkNotNull(url, "Failed to find " + FATHOM_PROPERTIES);

        try (InputStream stream = url.openStream()) {
            Properties prop = new Properties();
            prop.load(stream);

            version = prop.getProperty("version");

        } catch (IOException e) {
            LoggerFactory.getLogger(Constants.class).error("Failed to read '{}'", FATHOM_PROPERTIES, e);
        }

        Preconditions.checkNotNull(version, "The Fathom version is null!");

        return version;
    }