Java Question Child Classes possible?

barx

Well-Known Member
Licensed User
Longtime User
Are child classes possible / usable with b4a?

Here is what I'm trying to achieve.

B4X:
Dim DL as WearableDataLayer

    DL.Initialize("DL")
    DL.Connect
    ......
    ......

    DL.Message.Send(...........) <----

So I want a Message class inside the DataLayer class so that it's methods are accessed with DataLayer.Message.xxxxxx

Is this possible?

I tried the follow setup (Simplified for ease)

B4X:
@ShortName("WearableDataLayer")
Public Class WearableDataLayer {

    Public void Initialize() {
        ....
    }

    Public Class Message {

        Public void Send() {
            ....
        }
    }
}

This doesn't show anything in B4A for the Message class. If I add a @ShortName to the Message Class it is brought to B4A as it's own object to declare.

The reason I want this is 90% aesthetics, but there is a little functional reasoning as the message utilizes a GoogleApiClient that is previous connected in the DataLayer...

Any Ideas?

Thanks
 

barx

Well-Known Member
Licensed User
Longtime User
It doesn't seem to be working as you hoped Erel.

Inside my main class I have

B4X:
@Events(values={"MessageReceived(SourceNodeID As String, RequestID As String, Path As String, Data As String)"})
    public static class Message extends AbsObjectWrapper<MessageApi> implements MessageApi.MessageListener{
    ....
}

but no .Message. shows in B4A.

I will try by making a instance of it like LucaMs states
 

barx

Well-Known Member
Licensed User
Longtime User
I think that you are confusing a class with a class instance.

If the outer class will have a field that holds an instance of Message (named Message) then it will work.

It wouldn't be the first time I got confused, nor the first time I used the wrong terminology.....:confused:
 
Top