MCPcopy Create free account
hub / github.com/GcsSloop/SUtil / getVersionCode

Method getVersionCode

library/src/main/java/com/sloop/utils/AppUtils.java:51–60  ·  view source on GitHub ↗

获取程序版本号 @param context 上下文 @return 版本号

(Context context)

Source from the content-addressed store, hash-verified

49 * @return 版本号
50 */
51 public static int getVersionCode(Context context) {
52 int versionCode = -1;
53 String pkName = context.getPackageName();
54 try {
55 versionCode = context.getPackageManager().getPackageInfo(pkName, 0).versionCode;
56 } catch (PackageManager.NameNotFoundException e) {
57 e.printStackTrace();
58 }
59 return versionCode;
60 }
61}

Callers

nothing calls this directly

Calls 1

getPackageNameMethod · 0.80

Tested by

no test coverage detected