Skip to content

Commit 7dd0893

Browse files
committed
Use getLongVersionCode() unconditionally
Replace the SDK-version conditional for retrieving the app version code with a direct call to PackageInfo.getLongVersionCode(). This simplifies the code by removing the legacy branch that used the int versionCode and assumes compilation/targeting against API 28+ where getLongVersionCode() is available. No functional change to the returned string (versionName + "+" + versionCode).
1 parent 536cf85 commit 7dd0893

File tree

1 file changed

+1
-6
lines changed
  • src/serious_python_android/android/src/main/java/com/flet/serious_python_android

1 file changed

+1
-6
lines changed

src/serious_python_android/android/src/main/java/com/flet/serious_python_android/AndroidPlugin.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
6666
android.content.pm.PackageManager pm = context.getPackageManager();
6767
android.content.pm.PackageInfo info = pm.getPackageInfo(packageName, 0);
6868
String versionName = info.versionName;
69-
long versionCode;
70-
if (android.os.Build.VERSION.SDK_INT >= 28) {
71-
versionCode = info.getLongVersionCode();
72-
} else {
73-
versionCode = info.versionCode;
74-
}
69+
long versionCode = info.getLongVersionCode();
7570
result.success(versionName + "+" + versionCode);
7671
} catch (Exception e) {
7772
result.error("Error", e.getMessage(), null);

0 commit comments

Comments
 (0)