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 ackageName ="com.MyTestPgm"
'
Dim pm As PackageManager
AppVersion = pm.GetVersionName(PackageName)
'
' do some other stuff...
'
Log (" Application Package is: " & PackageName)
Log (" Application Version is:"& " " & AppVersion)
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 ackageName ="com.MyTestPgm"
'
Dim pm As PackageManager
AppVersion = pm.GetVersionName(PackageName)
'
' do some other stuff...
'
Log (" Application Package is: " & PackageName)
Log (" Application Version is:"& " " & AppVersion)