LAMW can I read versionName and versionCode programmatically? lazarus / 43-Android ---------------------------------------------------------------------- Manlio · 2020-10-31 15:32 I'd like to be able to read the values of android:versionName and android:versionCode (assigned in AndroidManifex.xml) from within my LAMW app. Is it possible? ---------------------------------------------------------------------- ADiV · 2020-10-31 19:04 If possible use the functions: self.GetVersionCode() and self.GetVersionName() ---------------------------------------------------------------------- Manlio · 2020-11-02 17:43 Quote from: ADiV on October 31, 2020, 08:04:20 pmself.GetVersionCode() and self.GetVersionName() I don't see those functions anywhere. What class of object is "self" in your example? I only see some code used in the IDE integration, where you can assign values that will be written in AndroidManifest.xml But I'd like to be able to read those values at runtime, from within the app itself. Right now I'm using a round-about way: I wrote a utility that runs before compilation, reads the values from the manifest file, and patches those values as constants in an include file, which will be compiled with the app. The app then gets the information from those constants. However I think it would be nice to have a way to just access that info from e.g. a jForm object, like in the case of various other environment-related variables such as package name, internal app directory, etc. ---------------------------------------------------------------------- software_developer · 2020-11-02 18:26 Hi ADiV, I was just checking the code in Controls.java, I have found a shorter alternative, possibly returns the same thing I guess. Code: Java  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i public String getVersionName() {    return BuildConfig.VERSION_NAME;} public String getVersionCode() {   return String.valueOf(BuildConfig.VERSION_CODE);} ---------------------------------------------------------------------- ADiV · 2020-11-02 19:27 Quote from: Manlio on November 02, 2020, 06:43:21 pmQuote from: ADiV on October 31, 2020, 08:04:20 pmself.GetVersionCode() and self.GetVersionName() I don't see those functions anywhere. What class of object is "self" in your example? I only see some code used in the IDE integration, where you can assign values that will be written in AndroidManifest.xml But I'd like to be able to read those values at runtime, from within the app itself. Right now I'm using a round-about way: I wrote a utility that runs before compilation, reads the values from the manifest file, and patches those values as constants in an include file, which will be compiled with the app. The app then gets the information from those constants. However I think it would be nice to have a way to just access that info from e.g. a jForm object, like in the case of various other environment-related variables such as package name, internal app directory, etc. These functions belong to the "jForm" class. I created them myself and included them in LAMW not long ago, maybe you don't use the latest version they are included in. Hence, belonging to jForm, I call them using self.GetVersionCode () For example, I use this feature in my latest QRiBar Scanner app: https://play.google.com/store/apps/details?id=adiv.QRiBar.QRiBar ---------------------------------------------------------------------- ADiV · 2020-11-02 19:35 Quote from: software_developer on November 02, 2020, 07:26:26 pmHi ADiV, I was just checking the code in Controls.java, I have found a shorter alternative, possibly returns the same thing I guess. Code: Java  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i public String getVersionName() {    return BuildConfig.VERSION_NAME;} public String getVersionCode() {   return String.valueOf(BuildConfig.VERSION_CODE);}Look at this link: https://stackoverflow.com/questions/38872907/android-buildconfig- version-name-returning-null The current implementation is the safest: Code: Java  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i // By ADiV        public int GetVersionCode(){                PackageManager pm = controls.activity.getPackageManager();                            try {                PackageInfo pinfo = pm.getPackageInfo(controls.activity.getPackageName(), 0);              return pinfo.versionCode;            } catch (NameNotFoundException e) {                return 0;            }        }         //By ADiV        public String GetVersionName(){                PackageManager pm = controls.activity.getPackageManager();                            try {                PackageInfo pinfo = pm.getPackageInfo(controls.activity.getPackageName(), 0);              return pinfo.versionName;            } catch (NameNotFoundException e) {                return "";            }        } ---------------------------------------------------------------------- jmpessoa · 2020-11-02 19:36 Quoteit would be nice to have a way to just access that info from e.g. a jForm object... I can confirme here....  in jForm self.GetVersionCode() and self.GetVersionName() ---------------------------------------------------------------------- Manlio · 2020-11-19 15:28 Quote from: jmpessoa on November 02, 2020, 08:36:06 pmQuoteit would be nice to have a way to just access that info from e.g. a jForm object... I can confirme here....  in jForm self.GetVersionCode() and self.GetVersionName() Thanks everyone, I was using a slightly older version, I see it now!