Skip to content

Commit

Permalink
Fixed package version code extraction according to current API level
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyor Goldstein committed Sep 21, 2023
1 parent 9b1b971 commit 5d93955
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ public String getVersionCode() {
try {
PackageManager pm = this.context.getPackageManager();
PackageInfo pkgInfo = pm.getPackageInfo(getPackageName(), 0);
versionCode = "" + pkgInfo.versionCode;
versionCode = (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P)
? Long.toString(pkgInfo.getLongVersionCode())
: Integer.toString(pkgInfo.versionCode)
;
} catch (PackageManager.NameNotFoundException e) {
}
}
Expand All @@ -249,7 +252,7 @@ public String getVersionName() {
return versionName != null ? versionName : "";
}

private String absPath(File file) {
private static String absPath(File file) {
return file != null ? file.getAbsolutePath() : "";
}
}

0 comments on commit 5d93955

Please sign in to comment.