From e00c334c265b4c0303b4afa7785f926657b08814 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Wed, 9 Mar 2022 18:31:18 +0100 Subject: [PATCH 1/2] fix(app): get correct build value --- .../main/java/com/capacitorjs/plugins/app/AppPlugin.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/app/android/src/main/java/com/capacitorjs/plugins/app/AppPlugin.java b/app/android/src/main/java/com/capacitorjs/plugins/app/AppPlugin.java index 8bf9b7378..7c7b28b4c 100644 --- a/app/android/src/main/java/com/capacitorjs/plugins/app/AppPlugin.java +++ b/app/android/src/main/java/com/capacitorjs/plugins/app/AppPlugin.java @@ -6,6 +6,7 @@ import android.net.Uri; import android.os.Build; import androidx.activity.OnBackPressedCallback; +import androidx.core.content.pm.PackageInfoCompat; import com.getcapacitor.JSObject; import com.getcapacitor.Logger; import com.getcapacitor.Plugin; @@ -75,11 +76,7 @@ public void getInfo(PluginCall call) { String appName = stringId == 0 ? applicationInfo.nonLocalizedLabel.toString() : getContext().getString(stringId); data.put("name", appName); data.put("id", pinfo.packageName); - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) { - data.put("build", Long.toString(pinfo.getLongVersionCode())); - } else { - data.put("build", Integer.toString(pinfo.versionCode)); - } + data.put("build", Integer.toString((int)PackageInfoCompat.getLongVersionCode(pinfo))); data.put("version", pinfo.versionName); call.resolve(data); } catch (Exception ex) { From 5868f48a3de7def2c1a27fd37814220123c1785f Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Wed, 9 Mar 2022 18:55:18 +0100 Subject: [PATCH 2/2] fmt --- .../src/main/java/com/capacitorjs/plugins/app/AppPlugin.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/android/src/main/java/com/capacitorjs/plugins/app/AppPlugin.java b/app/android/src/main/java/com/capacitorjs/plugins/app/AppPlugin.java index 7c7b28b4c..1f5727931 100644 --- a/app/android/src/main/java/com/capacitorjs/plugins/app/AppPlugin.java +++ b/app/android/src/main/java/com/capacitorjs/plugins/app/AppPlugin.java @@ -76,7 +76,7 @@ public void getInfo(PluginCall call) { String appName = stringId == 0 ? applicationInfo.nonLocalizedLabel.toString() : getContext().getString(stringId); data.put("name", appName); data.put("id", pinfo.packageName); - data.put("build", Integer.toString((int)PackageInfoCompat.getLongVersionCode(pinfo))); + data.put("build", Integer.toString((int) PackageInfoCompat.getLongVersionCode(pinfo))); data.put("version", pinfo.versionName); call.resolve(data); } catch (Exception ex) {