Android Question [Solved] Get name of current module

asales

Expert
Licensed User
Longtime User
If I use this code:
B4X:
Log(Me)
I get this information:
class br.com.myapplication.audio

How I can do to get only the name of the module: audio ?

Thanks in advance for any tips.
 

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
I think only the FQN is ever returned, store the me in a string and use .LastIndexOf(".")+1 to get the module name:
B4X:
...
   Log(ModuleName(me))
...

Public Sub ModuleName(Obj as Object) As String
   Dim psActName As String = Obj
   Return  psActName.SubString(psActName.LastIndexOf(".") + 1)
End Sub
Disclaimer - not tested, just typed in
 
Upvote 0

Cableguy

Expert
Licensed User
Longtime User
If in a future update the way the module reference is created changes, then the code will break.
Using a constant, the module name can even be something more meaningful and not necessarily the actual module name.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…