Hi,
I created a android client app with 5 activities.
It can connect(send and receive msg) my pc software.
1. I place AsyncStreams at First Activity
2. I can send message from any activity to pc. e.g FirstActivity.myAsync.Write("xxx")
3. But I only receive message at First Activity that coded AsyncStreams.
Question is:
How can I receive message from pc at other activities (Not First Activity)?
How can I declare globally sub [Sub mySocket_NewData(Buffer() As Byte) ] that can access from any activities?
Some code of my app are as follow:
'In First Activity
At Process_Globals
'In Second Activity
I can send message from Second Activity as follow:
I created a android client app with 5 activities.
It can connect(send and receive msg) my pc software.
1. I place AsyncStreams at First Activity
2. I can send message from any activity to pc. e.g FirstActivity.myAsync.Write("xxx")
3. But I only receive message at First Activity that coded AsyncStreams.
Question is:
How can I receive message from pc at other activities (Not First Activity)?
How can I declare globally sub [Sub mySocket_NewData(Buffer() As Byte) ] that can access from any activities?
Some code of my app are as follow:
'In First Activity
At Process_Globals
Public mySocket As Socket
Public myAsync As AsyncStreams
Public myMsg As String
Sub mySocket_Connected(Successful As Boolean)
If Successful Then
myAsync.Initialize(mySocket.InputStream,mySocket.OutputStream,"mySocket")
btnWiFi.Enabled =False
If pnlWiFi.Visible =True Then pnlWiFi.Visible =False
Else
mySocket.Close
btnWiFi.Enabled =True
End If
End Sub
Sub mySocket_NewData(Buffer() As Byte)
Dim mLine As String
Dim v As Int
mLine = BytesToString(Buffer,0,Buffer.Length,"UTF-8")
If mLine="good" Then
'bConnect=True
btnWiFi.Enabled=False
Else If mLine.SubString2(0,3) ="key" Then
v= mLine.SubString(mLine.Length-2)
slKey.SetValue(v)
End If
End Sub
'In Second Activity
I can send message from Second Activity as follow:
FirstActivity.myMsg ="Welcome"
FirstActivity.myAsync.Write(FirstActivity.myMsg.GetBytes("UTF8"))
Last edited: