B4J Question [solved] "This" class name.

Squiffy

Active Member
Licensed User
Longtime User
Can I get the name of the class I'm currently in?
So I could, for a trivial example, say :

B4X:
Log("You are inside class name " & ClassName)
 

mindful

Active Member
Licensed User
You need to do something like this:
B4X:
Dim MeName as String = Me
MeName = MeName.SubString("class ".Length)

Hope this helps ...
 
Upvote 0

Squiffy

Active Member
Licensed User
Longtime User
@mindful - doesn't work. It returns some variable and object info but nothing containing the class name.

Wondering if there is some JO method call I can make. Researching, but any pointers gratefully received...
 
Upvote 0

Squiffy

Active Member
Licensed User
Longtime User
Sussed it.

B4X:
Dim jo As JavaObject = Me
Dim ClassName As String=jo.RunMethod("getClass",Null)
Log("ClassName=" & ClassName)

Prints out

b4j.example.theclassname

Just need to strip it out.

Thanks to mindful for introducing me to Me :)
 
Upvote 0

Squiffy

Active Member
Licensed User
Longtime User
Just for completeness :

B4X:
Dim jo As JavaObject = Me
Dim ClassName As String=jo.RunMethod("getClass",Null)
ClassName=ClassName.SubString(ClassName.LastIndexOf(".")+1)
 
Upvote 0
Top