Android Question PackageManager, GetVersionCode("xxxx") too short

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Hi, I have Vertion Codes of 3 digits and GetVersionCode gets only the first 2 digits.
Any way of retreive it full?
Thanks
 

JohnC

Expert
Licensed User
Longtime User
The version code is set my the developer - it can be three digits long:
B4X:
#VersionCode: 101

Or it can be two digits:
B4X:
#VersionCode: 11

What is retuned by GetVersionCode should be the full number of digits the developer specified in the APK.

Why do you think it should be 3 digits?
 
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
I set the VersionCode of my app in 180 and GetVersionCode retreives 18
It seams it only happes when the last digit is zero.
 
Last edited:
Upvote 0

JohnC

Expert
Licensed User
Longtime User
I believe getversion"code" will drop trailing "0"s.

If you set it to 181, you should get back 181
 
Upvote 0

Erel

B4X founder
Staff member
Licensed User
Longtime User
I'm unable to reproduce it. Test it with this code:
B4X:
#Region  Project Attributes 
    #ApplicationLabel: B4A Example
    #VersionCode: 180
    #VersionName: 
    'SupportedOrientations possible values: unspecified, landscape or portrait.
    #SupportedOrientations: unspecified
    #CanInstallToExternalStorage: False
#End Region

#Region  Activity Attributes 
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.

End Sub

Sub Activity_Create(FirstTime As Boolean)
    Log(Application.VersionCode)
End Sub
 
Upvote 0

Alberto Michelis

Well-Known Member
Licensed User
Longtime User
Im using:
B4X:
Dim pm as PackageManager

VersionBuild = pm.GetVersionName("armi.portit")&"."&pm.GetVersionCode("armi.portit")
 
Upvote 0
Top