Android Question UDP in code modul

xunwichtig

Member
Licensed User
Hi,

i have a activity modul what starts a service modul. in this service modul a UDP network socket will inizialized in a code modul.

all this works fine, but i can't receive any messeges on this constelation. Send a packet works too, but no packet will received.
If i place the UDP into an single activity, then all works fine.


activity (main)
B4X:
Sub globals
End Sub

Sub Activity_Create(FirstTime As Boolean)
If FirstTime = True Then
   StartService(services)
End If
End Sub

Sub Activity_Resume
End Sub

Sub Activity_Pause(UserClosed As Boolean)
End Sub

code modul (globals)
B4X:
Sub Process_Globals
Dim G_NetworkUDP As UDPSocket
End Sub

Sub Network_Init()
Log("[!] Network-Init!")
G_NetworkUDP.Initialize("Network", 4554, 8000)
End Sub

Sub Network_Term()
Log("[!] Network-Term!")
G_NetworkUDP.Close()
End Sub

Sub Network_PacketArrived(Packet As UDPPacket)
Log("[!] Network-Packet!")
End Sub

service modul (services)
B4X:
#Region Service Attributes
   #StartAtBoot: False
#End Region

Sub Process_Globals
End Sub

Sub Service_Create
globals.Network_Init()
End Sub

Sub Service_Start(StartingIntent As Intent)
End Sub

Sub Service_Destroy
globals.Network_Term()
End Sub
and, this is what the log prints out:
B4X:
** Service (services) Create **
[!] Network-Init!
** Service (services) Start **

JimJim
XUN
 
Top