Reading the Application Version

hackhack

Active Member
Licensed User
Longtime User
In the editor you can set the "Application Version" - is there some way to read this version value from the app? Or do I have to maintain the number there as well?
 

Kevin

Well-Known Member
Licensed User
Longtime User
Ha ha... Well, I didn't say it was a perfect solution, but I figured it would answer your question (I had run across that post before).

Ideally, in the future we might get something like Application.Version but for what you are doing, I would just set a global variable as suggested in the other thread.
 
Upvote 0

hackhack

Active Member
Licensed User
Longtime User
Heh. I just thought that perhaps erel had defined a variable or something automatically picked it up.
 
Upvote 0

rbsoft

Active Member
Licensed User
Longtime User
Probably not the most elegant way, but you could define as first variable under Process_Globals one for the version info and assign it a value.


B4X:
Sub Process_Globals
   'These global variables will be declared once when the application starts.
   'These variables can be accessed from all modules.
   Dim VersionNo As String       :VersionNo = "0.9.42"

Alternatively you could set Major, Minor, and Revision separately in a type var.

Rolf
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Yeah thanks, I don't want to require a library just to read the version of my own app.
You shouldn't be concerned about using any library. Even the core functionality if Basic4android is a library, that's how it is structured so it is easy to add functionality.
 
Upvote 0

hackhack

Active Member
Licensed User
Longtime User
You shouldn't be concerned about using any library. Even the core functionality if Basic4android is a library, that's how it is structured so it is easy to add functionality.

Yeah, i guess what i meant was that i don't want to add unnecessary permissions - i assume most (if not all) libraries add extra permissions - and as a user i love apps which require few to no permissions.
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
i assume most (if not all) libraries add extra permissions - and as a user i love apps which require few to no permissions.
No. Permissions are only added when needed. Permissions are tied to objects not libraries.
When you call:
B4X:
Dim o As x
then the permissions of x object are added to your application.
The permissions are listed in the documentation. In the case of PackageManager, no permissions are added.
 
Upvote 0

hackhack

Active Member
Licensed User
Longtime User
No. Permissions are only added when needed. Permissions are tied to objects not libraries.

No, but surely most of the time you add some of the official libraries you get permissions requirements, because that's how you have grouped it??

The permissions are listed in the documentation.
Erm, I think the documentation is a bit lacking. And I wouldn't know where they were listed.


In the case of PackageManager, no permissions are added.

I see.
But since you are there, there isn't a variable or something (that you've added) which reads the version number one has entered in the b4a interface?
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
No, but surely most of the time you add some of the official libraries you get permissions requirements, because that's how you have grouped it??
Not sure what you mean. You can add all the libraries to your project and it will not add a single permission to your application.
Erm, I think the documentation is a bit lacking. And I wouldn't know where they were listed.
The documentation is available here: Android Programming Tutorials - Basic4android

But since you are there, there isn't a variable or something (that you've added) which reads the version number one has entered in the b4a interface?
No. The version you enter in the IDE is set in the manifest file. In some cases user need to manage the manifest file themselves. This means that it is not possible to rely on this value but rather the manifest value should be used.
Anyway using the PackageManager is a good solution and it doesn't add any permission. If you do not believe me you can just try it yourself.
 
Upvote 0

hackhack

Active Member
Licensed User
Longtime User
Not sure what you mean. You can add all the libraries to your project and it will not add a single permission to your application.

Sure, but you usually ad a library to use functions in it, no? :) Can you add all libraries and use all their functions and not need permissions?


Yes I know. Why are the german links at the top? Aren't most of us english reading? Shouldn't the German docs have a page of their own?
Doing a ctrl+f for 'permissions' doesn't hit anything.



No. The version you enter in the IDE is set in the manifest file. In some cases user need to manage the manifest file themselves. This means that it is not possible to rely on this value but rather the manifest value should be used.

Can you read the actual manifest file from inside the app?

Anyway using the PackageManager is a good solution and it doesn't add any permission. If you do not believe me you can just try it yourself.

Of course I believe you. I hope you don't think i suggested otherwise. You made this stuff, so I'm going to assume you generally know what you are talking about :)
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
Each object lists its permissions. For example here the permissions of the FTP object: Basic4android - Net
If there is no permission section then it means that the object doesn't add any permissions.

Can you read the actual manifest file from inside the app?
No. You can only access the information with PackageManager.
 
Upvote 0
Top