Need Package Name as entered in the IDE

raytronixsystems

Active Member
Licensed User
Longtime User
I have just finished some code that reads the Application Version String as entered into the IDE during the build process. It stows it away for an "about" screen and does some logging of the info (below). Reading from the system negates the need for maintaining a separate string inside the code. During each release I had to enter the Version String twice - One in the IDE and the second in my code and they were always out of sync.

When calling the subroutine GetVersionName one must supply the Package Name of the Application. This again is entered into the IDE at build time. There is a subroutine GetInstalledPackages to obtain the Package Name but it returns a List of ALL packages installed in the system and NOT only my Package. I don't think the list will do me much good unless I'm missing something here.Perhaps I am the nth entry in the list but not sure yet. I saw code up here that will return me the complete list but if I don't know where to look I'm in trouble.

I want to enter the Package Name and Version String Once in the IDE and not have to keep it in the code. How do I figure out which of the Packages in the returned list is MY application. Right now it works great if I declare it locally within my program but that's not acceptable. Here's a small code snippet of a
section of code that is logging the Package Name and Version Number:

Note: please remember that the Package Manager code is embedded in the Phone Library and must be included in the project or you will get a compile error.

code:
Dim AppVersion AS String
Dim PackageName As String :packageName ="com.MyTestPgm"
'
Dim pm As PackageManager
AppVersion = pm.GetVersionName(PackageName)
'
' do some other stuff...
'
Log (" Application Package is: " & PackageName)
Log (" Application Version is:"& " " & AppVersion)
 

raytronixsystems

Active Member
Licensed User
Longtime User
Hi Erel!

What is the argument "anywheresoftware.b4a.BA". Is it the name of my compiled executable or what? If it is, how would my program know it's name at run time?

For instance, let's say if my program is called "TestPgm.b4a". I enter a Package Name of "com.raytronixsystems.testpgm" in the IDE . My IDE Application Label is entered as "Test Pgm". My IDE Version String is entered as "1.00.00".

I would expect the reflection call to return the PackageName of "com.raytronixsystems.testpgm" so I could pass it on to retrieve the Application Version string of "1.00.00" for subsequent use. Which of these if any, do I use in my call to the Reflection libraryas you had advised?. This argument is a class name according to the documentation up here but not sure what that is at the moment.

thx,
Ray
 
Upvote 0

raytronixsystems

Active Member
Licensed User
Longtime User
Thanks Erel!

Works great!
-Ray
 
Upvote 0

eps

Expert
Licensed User
Longtime User
As always there are many ways of doing this, i just use the phone lib to retrieve this info.. I'll post the code later, but think I got it from a post here or documentation here.
 
Upvote 0
Top