Android Question How to call the same sub from one Activity to another one on IRC chat library

Sberla

Active Member
Licensed User
Longtime User

  1. I am trying to call a sub that is in the IRC Class (library) to have the same function in a second activity, but it doesn't behave as in the first Activity, I have declare the usernick as global but still don't send the messages.
    It gets the nick value from the first activity but doesn't send the message to the channel or other nicks.

    how can I use the sub in the second Activity, I have tried even with CallSub but nothing ?

    ****Activity 1 ****

    Sub Process_Globals
    Dim IRC As IRCClass ' Reference to the library

    'IRC.NickList Is Map containing the names of the chatters, and their mask , either !, @, %, in order of power, for hosting

    Dim Nick As String
    Dim Channel As String
    Dim Password As String
    Dim Server As String

    Dim result As String
    result=""

    End Sub

    Sub chat_RawFeed( data As String )

    '''Nick lists on Channel

    For i=0 To IRC.NickList.Size-1

    ListView2.AddSingleLine(IRC.NickList.GetKeyAt(i))
    Log(IRC.NickList.GetKeyAt(i))

    Next

    End Sub

    Sub SendMessage( Txt As String )

    If Txt.StartsWith("/") Then
    IRC.Send(Txt.SubString(1))
    Else
    IRC.Send("PRIVMSG " & Nick1 & " " & Txt)
    End If

    End Sub

    Sub Button1_Click

    If EditText1.Text <> "" Then

    SendMessage(EditText1.Text &CRLF)

    EditText1.Text=""

    End Sub

    Public Sub ListView2_ItemClick (Position As Int, Value As Object)
    result=Value
    StartActivity(chati)

    End Sub


    ********Activity 2 (chati)**************

    Sub SendMessage( Txt As String )

    If Main.result<>0 Then

    If Txt.StartsWith("/") Then
    IRC.Send(Txt.SubString(1))
    Else
    IRC.Send("PRIVMSG " & Main.result & " " & Txt)
    End If

    End If

    End Sub

    Sub Button2_Click

    If EditText1.Text <> "" Then

    SendMessage(EditText1.Text & CRLF)

    EditText1.Text=""

    End Sub
 

DonManfred

Expert
Licensed User
Longtime User
You are not new here; you should know that you should use code tags when posting code.
 
Upvote 0

Sberla

Active Member
Licensed User
Longtime User
I understand , below is a part of the code,,, how can I resolve my problem ???

B4X:
'****Activity 1 ****

Sub Process_Globals
Dim IRC As IRCClass ' Reference to the library


Dim Nick As String
Dim Channel As String
Dim Password As String
Dim Server As String

Dim result As String
result=""

End Sub

Sub chat_RawFeed( data As String )

'''Nick lists on Channel

For i=0 To IRC.NickList.Size-1

ListView2.AddSingleLine(IRC.NickList.GetKeyAt(i))
Log(IRC.NickList.GetKeyAt(i))

Next

End Sub

Sub SendMessage( Txt As String )

If Txt.StartsWith("/") Then
IRC.Send(Txt.SubString(1))
Else
IRC.Send("PRIVMSG " & Nick1 & " " & Txt)
End If

End Sub

Sub Button1_Click

If EditText1.Text <> "" Then

SendMessage(EditText1.Text &CRLF)

EditText1.Text=""

End Sub

Public Sub ListView2_ItemClick (Position As Int, Value As Object)
result=Value
StartActivity(chati)

End Sub


'********Activity 2 (chati)**************

Sub SendMessage( Txt As String )

If Main.result<>0 Then

If Txt.StartsWith("/") Then
IRC.Send(Txt.SubString(1))
Else
IRC.Send("PRIVMSG " & Main.result & " " & Txt)
End If

End If

End Sub

Sub Button2_Click

If EditText1.Text <> "" Then

SendMessage(EditText1.Text & CRLF)

EditText1.Text=""

End Sub
 
Upvote 0

Sberla

Active Member
Licensed User
Longtime User
Well I have moved the sub SendMessage to a service and on the second activity have called the service with a callsub, but still no result ???

B4X:
Sub Button2_Click
 
    If EditText1.Text <> "" Then
     
        CallSub(ssend,"SendMessage")
 
    Else
        Msgbox("No message","Alert")
      
    End If

    EditText1.Text=""
 
End Sub

error

java.lang.Exception: Sub sendmessage signature does not match expected signature.
public static anywheresoftware.b4a.pc.RemoteObject b4a.example.ssend_subs_0._sendmessage(anywheresoftware.b4a.pc.RemoteObject) throws java.lang.Exception
 
Last edited:
Upvote 0
Top