Android Question know from what class is derived an object

Roberto P.

Well-Known Member
Licensed User
Longtime User
I need to know what class is derived an object of custom controls.

I know the function:

Code:
If CallBack Is Activity Then

end if

specifically I need to know the class membership of the object that is passed in the custom controls.

Code:
Public Sub Initialize (vCallback As Object, vEventName As String)
    EventName = vEventName
    CallBack = vCallback
   
    If CallBack Is Activity Then
        Log("è una activita")
    else if CallBack Is Panel Then
        Log("è un pannello")
    End If
   
End Sub

thanks
 
If you needed only to know:
If CallBack Is Activity Then

maybe you can use (or adapt) this routine (it is from module Scale):
Code:
'Returns True If the View v Is an Activity otherwise False
'Needed to check if the view is a Panel or an Activity
Public Sub IsActivity(v As View) As Boolean
    Dim obj As Object
    obj = GetParent(v)
    If GetType(obj) = "android.widget.FrameLayout" Then
        Return True
    Else
        Return False
    End If
End Sub
 
Upvote 0
It is difficult to distinguish between activities and panels because both of them are based on the same internal type.

What do you need it for?

I need to know what is the parent class of the object, to make the correct cast with the subject "vCallback"
So, how do I know which class an object belongs?
I hope it is clear
 
Upvote 0
Back
Top