Android Question Unknown type CharSequence

Alessandro71

Active Member
Licensed User
while writing a wrapper for MsgboxAsync, i'm getting the unknown type error
B4X:
Public Sub ShowMsgboxAsync(message As CharSequence, title As CharSequence) As Object
    Log(message)
    Return xui.MsgboxAsync(message, title)
End Sub
what's the correct way to write such a wrapper?

the intended behavior should be logging message boxes as they are presented to the user (and hopefully logging the answer for MsgboxAsync2 also, but that seems to be a whole different matter)
 

Star-Dust

Expert
Licensed User
B4X:
Public Sub ShowMsgboxAsync(message As Object, title As Object) As Object
    Dim msg as string = message
    Log(msg)
    Return xui.MsgboxAsync(message, title)
End Sub
 
Upvote 0

Star-Dust

Expert
Licensed User
In fact, if you want the answer, the code would be like this
B4X:
Public MainSub
    Wait For (ShowMsgboxAsync(message, title)) Complete (Result As Int)
End Sub

Public Sub ShowMsgboxAsync(message As Object, title As Object) As ResumableSub
    Dim msg as string = message
    Log(msg)

    Wait For (xui.MsgboxAsync("Hello", "World")) Msgbox_Result (Result As Int)
    Return Result
End Sub
In any case, not interested in the answer even with the previous method it works but does not return anything

But if you use CharSequence / CSBuilder you have to set them as Object not as String
 
Last edited:
Upvote 0

Alessandro71

Active Member
Licensed User
actually i'm working on something less convoluted, that can be used as direct replacement for the xui version

B4X:
Public Sub ShowMsgboxAsync(message As Object, title As Object) As Object
    Dim msg As String = message
    WriteLog(msg.Replace(CRLF, "|"))
    Return xui.MsgboxAsync(message, title)
End Sub

'before:
    Dim sf As Object = xui.MsgboxAsync("No device found.", "Error")
    Wait For (sf) Msgbox_Result (Result As Int)

'after:
    Dim sf As Object = ShowMsgboxAsync("No device found.", "Error")
    Wait For (sf) Msgbox_Result (Result As Int)

this is easy for MsgboxAsync, but willing to log the answer to Msgbox2Async also, a similar direct replacement seems not possible, as the logging of the answer should be after the Wait, and thus in the main code
 
Upvote 0
Top