Android Question Get package name of current program?

techknight

Well-Known Member
Licensed User
Longtime User
Right now, I am doing something goofy like this:

B4X:
    #IF BS04
         ToolbarHelper.Subtitle = "V" & Common.Left(pm.GetVersionName("md.smbs04"), 3) & "." & Common.Right(pm.GetVersionName("md.smbs04"), 1)
    #END IF
    #IF BS051C
         ToolbarHelper.Subtitle = "V" & Common.Left(pm.GetVersionName("md.smbs051c"), 3) & "." & Common.Right(pm.GetVersionName("md.smbs051c"), 1)
    #END IF      
    #IF 2B
         ToolbarHelper.Subtitle = "V" & Common.Left(pm.GetVersionName("md.smbaseball2b"), 3) & "." & Common.Right(pm.GetVersionName("md.smbaseball2b"), 1)
    #END IF
    #IF BS05
         ToolbarHelper.Subtitle = "V" & Common.Left(pm.GetVersionName("md.smbs05"), 3) & "." & Common.Right(pm.GetVersionName("md.smbs05"), 1)
    #END IF  
    #IF BS17
         ToolbarHelper.Subtitle = "V" & Common.Left(pm.GetVersionName("md.smbs17"), 3) & "." & Common.Right(pm.GetVersionName("md.smbs17"), 1)
    #END IF  
    #IF BS02 and Not(HE)
         ToolbarHelper.Subtitle = "V" & Common.Left(pm.GetVersionName("md.smbs02"), 3) & "." & Common.Right(pm.GetVersionName("md.smbs02"), 1)
    #END IF  
    #If BS02 and HE
        ToolbarHelper.Subtitle = "V" & Common.Left(pm.GetVersionName("md.smbs02he"), 3) & "." & Common.Right(pm.GetVersionName("md.smbs02he"), 1)
    #End If
    #IF BS031
         ToolbarHelper.Subtitle = "V" & Common.Left(pm.GetVersionName("md.smbs031"), 3) & "." & Common.Right(pm.GetVersionName("md.smbs031"), 1)
    #END IF      
    #IF BS01 and not(PC) and Not(HE)
         ToolbarHelper.Subtitle = "V" & Common.Left(pm.GetVersionName("md.smbs01"), 3) & "." & Common.Right(pm.GetVersionName("md.smbs01"), 1)
    #END IF  
    #if (BS01 and Not(PC)) and HE
        ToolbarHelper.Subtitle = "V" & Common.Left(pm.GetVersionName("md.smbs01he"), 3) & "." & Common.Right(pm.GetVersionName("md.smbs01he"), 1)
    #End If
    #IF BS01 and PC
         ToolbarHelper.Subtitle = "V" & Common.Left(pm.GetVersionName("md.smbs01pc"), 3) & "." & Common.Right(pm.GetVersionName("md.smbs01pc"), 1)
    #END IF      
    #IF BS02PCCLK
         ToolbarHelper.Subtitle = "V" & Common.Left(pm.GetVersionName("md.smbs02pcclk"), 3) & "." & Common.Right(pm.GetVersionName("md.smbs02pcclk"), 1)
    #END IF

I use the above to display the version info on the titlebar. Trouble is, its painful.

Is there a way to simplify this and just get the current running package name so i can return the version of the currently running program?
 

DonManfred

Expert
Licensed User
Longtime User
B4X:
    Log(Application.PackageName)
    Log(Application.VersionCode)
    Log(Application.VersionName)
 
Upvote 0
Solution
Top